A __matlab of the practice of MATLAB introduction

Source: Internet
Author: User
Tags cos sin

Provide a few introductory miscellaneous examples for the first time to touch matlab people pondering. The beauty of Matlab lies in the simplicity of its code and its use in various industries. tiredness and product and upper and lower triangles

CLC
Clear
a=magic (9)
cumsum (a)
prod (a,2)% by line Triu (
a)% upper triangular 
tril (ones (4,4), -1)
a=[2 1-1;2 1 0;1-1 1]
b=[1-1 3;4 3 2]
x=b/a x*a a*b
'
Factoring, character definition, determinant, simplification, Tong, etc brief Operation
CLC
Clear
syms percent x defines variable
f=factor (x^9-1)% factorization
x=sym (' x ')
m=sym (' [a,b;c,d] ')
det ( Magic (3))
det (M)
%simple% simplify
simplify (cos (x) ^2+sin (x) ^2) Simple
(cos (x) ^2+sin (x) ^2)
[N, D]=numden (f)% Tong
factor (sym (' 239239893849832 '))
% expand%  expand
% collect
% similar terms Find variables

a small exploration of t distribution
CLC
Clear
syms y
syms n x H
f=exp ((-(n+x^2) *y^2)/2 *y^ (n)
pretty (y)
h=int (F,y,0,inf)
Simplify (Y)

a=n^ (N/2)/(2^ (N/2-1/2)) y=h*a P=gamma


((n+1)/2)/SQRT (n) * (1+x^2/n) ^ ((n+1)/2)
pretty (f)
y-p
Simplify (p)
determination of Planck constant in the experiment of large objects
x1=[4.57 3.96 3.58 2.94 1.90 0.86 0.12-0.73-1.24-1.73-1.91-1.95-2.00-2.05-2.10-2.15-2.40-2.50-2.55-2.65] Y1=[ 42.6*10^-9 38.0*10^-9 33.5*10^-9 30.0*10^-9 18.5*10^-9 10.7*10^-9 61.4*10^-10 23.5*10^-10 70.1*10^-11 38.0*10^-12-20*10 ^-12-21.5*10^-12-25.5*10^-12-26.5*10^-12-30.4*10^-12-30*10^-12-37.5*10^-12-40*10^-12-40.7*10^-12-40*10^-12] X2= [4.5 3.5 2.51 1.50 0.50-0.17-0.7-1.14-1.36-1.40-1.44-1.50-1.58-1.68-1.77-1.78-1.86-1.95-2.09-2.17-2.27-2. 30-2.42-2.52-2.63-2.74-2.80-2.74-2.85] y2=[13.4*10^-9 11.1*10^-9 85.1*10^-10 58.3*10^-10 29.1*10^-10 13.8*10^-10 4 4*10^-11 37.6*10^-12 27.7*10^-13 4.8*10^-13-26.7*10^-13-59.9*10^-13-81.2*10^-13-98*10^-13-99.5*10^-13-99.6*10^-13 -13.8*10^-13-14.5*10^-13-14.2*10^-13-15.2*10^-13-14.2*10^-13-14.4*10^-13-14.1*10^-13-14.82*10^-13-16.8*10^-13- 13.9*10^-13-14.0*10^-13-14.4*10^-13-14.4*10^-13] x3=[4.64 3.48 2.70 2.01 1.72 1.56 1.15 0.97 0.30-0.03-1.18-1.21-1. 2-1.25-1.33-1.36-1.48-1.53-1.56-1.64-1.72-1.81-1.91] y3=[11.6*10^-9 10.0*10^-9 82.0*10^-10 62.0*10^-10 58.5*10^-10 50.6*10^-10 40.1*10^-10 34.0* 10^-10 17.0*10^-10 10.3*10^-10 57.7*10^-13 9.3*10^-13-6.9*10^-13-20.0*10^-13-55*10^-13-32.8*10^-13-59.5*10^-13- 67.7*10^-13-70.2*10^-13-73.8*10^-13-82.6*10^-13-82.0*10^-13-88.5*10^-13] x4=[4.58 3.98 2.95 2.68 1.96 0.18-0.38-0.5 5-0.65-0.68-0.73-0.78-0.8-0.83-0.87-0.95-1.00-1.08-1.43-1.60-1.75] y4=[14.3*10^-9 12.2*10^-9 10.0*10^-9 88.3* 10^-10 71.7*10^-10 16.3*10^-10 16.7*10^-11 31.7*10^-12 90.0*10^-13 68.0*10^-13 15.0*10^-13-13.0*10^-13-30.9*10^-13-34 *10^-13-42*10^-13-50.5*10^-13-60*10^-13-66.7*10^-13-72.3*10^-13-70.0*10^-13-74.2*10^-13] X5=[4.07 3.72 1.97 1.28 0. 0.21-0.29-0.53-0.58-0.61-0.66-0.68-0.75-0.78-0.83-0.90-1.00-1.13-1.23-1.38-1.47] Y5=[62.1*10^-10 53.3*1 0^-10 40.3*10^-10 24.4*10^-10 14.7*10^-10 69.2*10^-11 84.8*10^-12 60.2*10^-13 33.9*10^-13-9.6*10^-13-7.3*10^-13-11.3* 10^-13-18.4*10^-13-21.9*10^-13-24.7*10^-13-26.6*10^-13-30.0*10^-13-29.5*10^-13-28.7*10^-13-28.0*10^-13-31.5*10^-13] X6=[4.51 3.97 3.61 2.41 1.99 0  .65 0.02-0.48-0.57-0.60-0.64-0.67-0.74-0.82-0.86-0.89-0.96-1.03-1.07-1.35-1.43-1.65-1.82-2.02-2.26-2.61 -2.82-3.2] y6=[11.4*10^-10 10.0*10^-10 85.9*10^-11 65.2*10^-11 57.0*10^-11 23.5*10^-11 73.8*10^-12 33.6*10^-13 10.0*10 ^-13 6.0*10^-13 3.7*10^-13 1.9*10^-13-0.4*10^-13-1.1*10^-13-1.5*10^-13-2.0*10^-13-2.3*10^-13-2.3*10^-13-2.3*10^- 13-2.4*10^-13-1.7*10^-13-2.2*10^-13-2.5*10^-13-3.2*10^-13-3.2*10^-13-3.0*10^-13-3.1*10^-13-3.5*10^-13] X7=[4.50 3.11 1.81 1.16 0.25-0.20-0.44-0.48-0.54-0.62-0.65-0.68-0.71-0.74-0.77-0.78-0.97-1.21] y7=[14.9*10^-9 11.2*10^ -9 77.6*10^-10 60.0*10^-10 17.2*10^-10 32.5*10^-11 35.8*10^-12 21.0*10^-12 89.8*10^-13-10.2*10^-13-28.0*10^-13-58.0* 10^-13-63.0*10^-13-72.0*10^-13-67.4*10^-13-82.2*10^-13-92.0*10^-13-90.2*10^-13] Plot (X1,Y1) plot (X2,Y2) plot (X3, Y3) plot (x4,y4) plot (x5,y5) hold on

Plot (X6,Y6) hold on plot (X7,Y7) 
the use of ksdensity
CLC
Clear
X=[randn (30,1); 5+randn (30,1)];% produces 60 sample values
[F,xi]=ksdensity (x);% returns XI more than X quantity
subplot ( 2,2,1);
Plot (x);
Title (' Sample Data ');
Subplot (2,2,2);
Plot (xi,f);
Title (' Probability density distribution (PDF) ');
Subplot (2,2,3);
f= ksdensity (x,xi); 
Plot (xi,f); 
Subplot (2,2,4);
f= ksdensity (x,xi, ' function ', ' CDF '); 
Plot (xi,f); 




- use of Gplot

x=[0,0;1,0</

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.