单元数组(cell)
>> A(1,1)={[1 2 3;4 5 6;7 8 9]};%用索引赋值
>> A(2,1)={3+3i};
>> A(1,2)={'Matrice Laboratory'};
>> A(2,2)={0:0.2:5*pi};
>> A
A =
[3x3 double] 'Matrice Laboratory'
[3.0000 + 3.0000i] [1x79 double]
>> A{1,1}={[7+8*i],[7]}
A =
{1x2 cell} 'Matrice Laboratory'
[3.0000 + 3.0000i] [1x79 double]
clear
clc
y=[1 0.5 0.375 0.25 0.15 0.1 0.05 0];
color={[0.8 0.6 0.1],[0 0 0],[1 1 0],[1 0 0],[0 1 1],[0 1 0],[0 0 1],[0.5 0.5 0.5],[1 0 1],[0 0.7 0.4]};
x=0:0.01:5;
B=((-x.^2.+1).^2+(2*y(1,1).*x).^2).^(-1);
hold on
plot(x,B,'color',color{1},'LineWidth',1.4)
grid on
axis([0 5 0 3.5])
for i=2:length(y)
B=((-x.^2.+1).^2+(2*y(1,i).*x).^2).^(-1);
plot(x,B,'color',color{i},'LineWidth',1.4);
end
legend('ζ=1','ζ=0.5','ζ=0.375','ζ=0.25','ζ=0.15','ζ=0.1','ζ=0.05','ζ=0')
ylabel('振幅放大系数β')
xlabel('频率比λ')
for i=1:length(y)
str=num2str(y(i));
gtext(['ζ=' str])
end
refline(0,1);%绘制以0位斜率,1位截距的直线
plot([4 4],[0,3.5],'k')%绘制点(4,0)到点(4,3.5)的直线段
s=input('Please save picture');
y=[1 0.7 0.375 0.15 0.05];%ψ
figure(2);
hold on
x=0:0.01:1;
for i=1:length(y)
ang=atand((2*y(i).*x)./(1-x.^2));
plot(x,ang,'color',color{i+1},'LineWidth',1.4);
end
axis([0 5 0 180])
x=1.01:0.01:5;
y=[1 0.7 0.375 0.15 0.05];%ψ
% figure(2);
for i=1:length(y)
ang=180+atand((2*y(i).*x)./(1-x.^2));
plot(x,ang,'color',color{i+1},'LineWidth',1.4);
axis([0 5 0 180])
end
legend('ζ=1','ζ=0.7','ζ=0.375','ζ=0.15','ζ=0.05')
for i=1:length(y)
str=num2str(y(i));
gtext(['ζ=' str])
end
grid on
ylabel('相位差ψ')
xlabel('频率比λ')