>> 5^2
ans =
25
>> COS(pi)
Undefined function 'COS'for input arguments of type 'double'.
Did you mean:
>> cos(pi)
ans =
-1
>> x=[12345];
>> y=[1020304050];
>> plot(x,y)
>> isvarname time
ans =
logical
1
>> A=[3,1,-1;1,2,4;-1,4,5];
>> B=[3.6,2.1,-1.4];
>> X=A/B
X =
0.73980.1138
-0.1138
>> x=0:6x =
0123456
>> x=0:0.01:6;
>> y=[sin(1*x);sin(1*x^2);sin((1*x)^2)];
Error using ^
One argument must be a square matrix and the other must be a
scalar. Use POWER (.^) for elementwise power.
>> y=[sin(1*x);sin(1*x.^2);sin((1*x).^2)];
>> plot(x,y)
>> (12+2*(7-4))/3^2
ans =
2
>> z1=3+4i;
>> z2=1+2i;
>> z3=2*e^(pi*i/6);
Undefined function or variable 'e'.
>> z3=2e^(pi*i/6);
z3=2e^(pi*i/6);
↑
Error: Unexpected MATLAB operator.
>> z3=2*exp(pi*i/6);
>> z=(z1*z2)/z3;
>> z
z =
0.3349 + 5.5801i
>> x=0:0.01:15;
>> y=[sin(1*x);cos(1:x);1*exp(x),x^2];
Error using ^
One argument must be a square matrix and the other must be a
scalar. Use POWER (.^) for elementwise power.
>> y=[sin(1*x);cos(1:x);1*exp(x),x.^2];
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
>> y=[sin(1*x);cos(1:x);1.*exp(x),x.^2];
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
>> y=[sin(1*x);cos(1*x);1.*exp(x),x.^2];
Error using vertcat
Dimensions of matrices being concatenated are not consistent.
>> y=[sin(1*x);cos(1:x);1.*exp(x);x.^2];
>> plot(x,y)
>> y=[sin(1*x);cos(1*x);1*exp(x);x.^2];
>> plot(x,y)
>> plot(x,y)
>> t=0:0.01:4*pi;
>> y=[exp(-t/3)*sin(3*t);exp(-t/3)];
Error using *
Inner matrix dimensions must agree.
>> x=0:pi/10:2*pi;
>> y=sin(2.*x)+cos(x);
>> plot(x,y,'r-','LineWidth',1.5);xlabel('x'),ylable('y(x)';grid on legend('y=sin(2*x)+cos(x)'),1)
plot(x,y,'r-','LineWidth',1.5);xlabel('x'),ylable('y(x)';grid on legend('y=sin(2*x)+cos(x)'),1)
↑
Error: Unbalanced or unexpected parenthesis or bracket.
>> )plot(x,y,'r-','LineWidth',1.5);xlabel('x'),ylable('y(x)');grid on legend('y=sin(2*x)+cos(x)'),1)
)plot(x,y,'r-','LineWidth',1.5);xlabel('x'),ylable('y(x)');grid on legend('y=sin(2*x)+cos(x)'),1)
↑
Error: Unbalanced or unexpected parenthesis or bracket.
>> plot(x,y,'r-','LineWidth',1.5);xlabel('x'),ylable('y(x)');grid on legend('y=sin(2*x)+cos(x)'),1)
plot(x,y,'r-','LineWidth',1.5);xlabel('x'),ylable('y(x)');grid on legend('y=sin(2*x)+cos(x)'),1)
↑
Error: Unbalanced or unexpected parenthesis or bracket.
>> plot(x,y,'r-','LineWidth',1.5);xlabel('x'),ylable('y(x)');grid on legend('y=sin(2*x)+cos(x)'),1);
plot(x,y,'r-','LineWidth',1.5);xlabel('x'),ylable('y(x)');grid on legend('y=sin(2*x)+cos(x)'),1);
↑
Error: Unbalanced or unexpected parenthesis or bracket.
>> plot(x,y,'r-','LineWidth',1.5);xlabel('x'),ylable('y(x)');grid on);
Undefined function or variable 'ylable'.
>> legend('y=sin(2*x)+cos(x)',1)
Warning: There is no axes with which to associate a legend.
> In legend (line 204)
ans =
0×0 empty GraphicsPlaceholder array.
>> legend('y=sin(2x)+cos(x)',1);
Warning: There is no axes with which to associate a legend.
> In legend (line 204)
>> plot(x,y)
>> xa=-2:0.2:2;
>> ya=xa;
>> [x,y]=meshgrid(xa,ya);
>> %生成网格数据
>> %计算纵轴数据
>> z=x.*exp(-x.^2-y.^2);
>> mesh(x,y,z)
>> xa=-8:0.1:8;
>> ya=-8:0.1:8
ya =
Columns 1 through 7
-8.0000 -7.9000 -7.8000 -7.7000 -7.6000 -7.5000 -7.4000
Columns 8 through 14
-7.3000 -7.2000 -7.1000 -7.0000 -6.9000 -6.8000 -6.7000
Columns 15 through 21
-6.6000 -6.5000 -6.4000 -6.3000 -6.2000 -6.1000 -6.0000
Columns 22 through 28
-5.9000 -5.8000 -5.7000 -5.6000 -5.5000 -5.4000 -5.3000
Columns 29 through 35
-5.2000 -5.1000 -5.0000 -4.9000 -4.8000 -4.7000 -4.6000
Columns 36 through 42
-4.5000 -4.4000 -4.3000 -4.2000 -4.1000 -4.0000 -3.9000
Columns 43 through 49
-3.8000 -3.7000 -3.6000 -3.5000 -3.4000 -3.3000 -3.2000
Columns 50 through 56
-3.1000 -3.0000 -2.9000 -2.8000 -2.7000 -2.6000 -2.5000
Columns 57 through 63
-2.4000 -2.3000 -2.2000 -2.1000 -2.0000 -1.9000 -1.8000
Columns 64 through 70
-1.7000 -1.6000 -1.5000 -1.4000 -1.3000 -1.2000 -1.1000
Columns 71 through 77
-1.0000 -0.9000 -0.8000 -0.7000 -0.6000 -0.5000 -0.4000
Columns 78 through 84
-0.3000 -0.2000 -0.100000.10000.20000.3000
Columns 85 through 910.40000.50000.60000.70000.80000.90001.0000
Columns 92 through 981.10001.20001.30001.40001.50001.60001.7000
Columns 99 through 1051.80001.90002.00002.10002.20002.30002.4000
Columns 106 through 1122.50002.60002.70002.80002.90003.00003.1000
Columns 113 through 1193.20003.30003.40003.50003.60003.70003.8000
Columns 120 through 1263.90004.00004.10004.20004.30004.40004.5000
Columns 127 through 1334.60004.70004.80004.90005.00005.10005.2000
Columns 134 through 1405.30005.40005.50005.60005.70005.80005.9000
Columns 141 through 1476.00006.10006.20006.30006.40006.50006.6000
Columns 148 through 1546.70006.80006.90007.00007.10007.20007.3000
Columns 155 through 1617.40007.50007.60007.70007.80007.90008.0000
>> xa=-8:0.1:8;
>> ya=-8:0.1:8;
>> z=(sin((x^2+y^2)^(1/2)))/((x*2+y*2)^(1/2));
>> mesh(x,y,z);
Error using mesh (line 83)
X, Y, Z, and C cannot be complex.
>> [x,y]=meshgrid(xa,ya);
>> z=(sin((x^2+y^2)^(1/2)))/((x*2+y*2)^(1/2));
>> mesh(x,y,z);
Error using mesh (line 83)
X, Y, Z, and C cannot be complex.
>> z=(sin((x.^2+y.^2).^(1/2)))/((x*2+y*2).^(1/2));
>> mesh(x,y,z);
Error using mesh (line 83)
X, Y, Z, and C cannot be complex.
>> z=(sin((x.^2+y.^2).^(1/2)))/((x.*2+y.*2).^(1/2));
>> mesh(x,y,z)
Error using mesh (line 83)
X, Y, Z, and C cannot be complex.
>> xa=-8:0.1:8;
>> ya=xa;
>> [x,y]=meshgrid(xa,ya);
>> z=(sin((x.^2+y.^2).^(1/2)))/((x.*2+y.*2).^(1/2));
>> mesh(x,y,z);
Error using mesh (line 83)
X, Y, Z, and C cannot be complex.
>> %mesh不能处理复数
>> xa=-8:0.1:8;
>> ya=xa;
>> [x,y]=meshgrid(xa,ya);
>> z=sin(sqrt(x*2+y*2))/(sqrt(x*2+y*2));
>> mesh(x,y,z);
Error using mesh (line 83)
X, Y, Z, and C cannot be complex.
>> xa=-8:0.1:8;
>> ya=xa;
>> [x,y]=meshgrid(xa,ya);
>> z=(sin(sqrt(x^2+y^2)))/(sqrt(x^2+x^2));
Warning: Matrix is singular to working precision.
>> z=(sin(sqrt(x.^2+y.^2)))/(sqrt(x.^2+x.^2));
Warning: Matrix is singular to working precision.
>> %求矩阵的时候产生了奇异
>> xa=-8:0.4:8;
>> ya=xa;
>> [x,y]=meshgrid(xa,ya);
>> z=(sin(sqrt(x.^2+y.^2)))/(sqrt(x.^2+x.^2));
Warning: Matrix is singular to working precision.
>> z=(sin(sqrt(x.^2+y.^2)))./(sqrt(x.^2+x.^2));
>> plot(x,y)
>> mesh(x,y,z);
>> %产生奇异就是因为不是z=a./b没有.
>> A=[156;286;297];
>> B=[483;521;769];
>> A+B
ans =
5139710791516
>> A-B;
>> A-B
ans =
-3 -33
-365
-53 -2
>> %如果语句后面不加;就不会出现结果
>> A*B
ans =
7154629068681027678
>> A^2
ans =
2399783012810234145115
>> A
A =
156286297
>> A^(-1)
ans =
0.50004.7500 -4.5000
-0.5000 -1.25001.50000.50000.2500 -0.5000
>> %点积
>> dot(A,B)
ans =
2811087
>> %叉积
>> cross(a,b)
Undefined function or variable 'a'.
Did you mean:
>> cross(A,B)
ans =
43047142 -33
-3 -54 -12
>> %卷积
>> conv(A,B)
Error using conv (line 28)
A and B must be vectors.
>> A
A =
156286297
>> %转置
>> x=A.'
x =
1 2 2
5 8 9
6 6 7
>> %画三维球体
>> %elipsoid函数在三维立体空间画椭圆
>> [x,y,x]=ellipsoid(8,9,10,2,2,2);
>> surf(x,y,z);
Error using surf (line 82)
Data dimensions must agree.
>> [x,y,z]=ellipsoid(8,9,10,2,2,2);
>> surf(x,y,z);
>> %直接画出了球体
>> axis equal %保证各个维度长短一致
>> axis([1 50 1 50 1 0])
Error using matlab.graphics.axis.Axes/set
Value must be a 1x2 vector of numeric type in which the second element is
larger than the first and may be Inf
Error in axis>LocSetLimits (line 279)
set(ax,...
Error in axis (line 101)
LocSetLimits(ax(j),cur_arg,names);
>> axis([1 50 1 50 1 0]);
Error using matlab.graphics.axis.Axes/set
Value must be a 1x2 vector of numeric type in which the second element is
larger than the first and may be Inf
Error in axis>LocSetLimits (line 279)
set(ax,...
Error in axis (line 101)
LocSetLimits(ax(j),cur_arg,names);
>> axis([1 50 1 50 1 0]);
Error using matlab.graphics.axis.Axes/set
Value must be a 1x2 vector of numeric type in which the second element is
larger than the first and may be Inf
Error in axis>LocSetLimits (line 279)
set(ax,...
Error in axis (line 101)
LocSetLimits(ax(j),cur_arg,names);
>> axis([1 50 1 50 1 0]);
Error using matlab.graphics.axis.Axes/set
Value must be a 1x2 vector of numeric type in which the second element is
larger than the first and may be Inf
Error in axis>LocSetLimits (line 279)
set(ax,...
Error in axis (line 101)
LocSetLimits(ax(j),cur_arg,names);
>> %画三维球体
>> R=5;
>> [x,y,z]=sphere(50);
>> mesh(R*x,R*y,R*z)%上一步生成点 下一步画图
>>
>>