Changing from 'bar' command to 'plot' command.

1 次查看(过去 30 天)
Double expansion chamber program:
l1=0.05;
l3=0.05;
l5=0.05;
l2=0.200;
l4=0.200;
d1=0.05;
d3=d1;
d5=d1;
d2=0.25;
d4=d2;
M=0;
S1=pi/4*d1*d1;
S3=S1;
S5=S1;
S2=pi/4*d2*d2;
S4=S2;
for z=1:4500;
k=2*pi*z/343;
SP1=[cos(k*l1) 1i*sin(k*l1); 1i*sin(k*l1) cos(k*l1)]; % 2X2 matrix
TP1=[1 0; 0 S2/S1];
SP2=[cos(k*l2) 1i*sin(k*l2); 1i*sin(k*l2) cos(k*l2)];% 2X2 matrix
TP2=[1 0; 0 S3/S2];
SP3=[cos(k*l3) 1i*sin(k*l3); 1i*sin(k*l3) cos(k*l3)];% 2X2 matrix
TP3=[1 0; 0 S4/S3];
SP4=[cos(k*l4) 1i*sin(k*l4); 1i*sin(k*l4) cos(k*l4)];% 2X2 matrix
TP4=[1 0; 0 S5/S4];
SP5=[cos(k*l5) 1i*sin(k*l5); 1i*sin(k*l5) cos(k*l5)];% 2X2 matrix
TLM=SP1*TP1*SP2*TP2*SP3*TP3*SP4*TP4*SP5; % 2X2 matrix
Sum=TLM(1,1)+TLM(2,2)+TLM(2,1)+TLM(1,2);
Mag=abs(Sum);
TL(z)=20*log10(Mag/2);
f(z)=z;
end;
figure(1)
bar(f,TL,'y');
xlabel('FREQUENCY in Hertz');
ylabel('TRANSMISSION LOSS IN dB');
title('Plot of TRANSMISSION LOSS Versus FREQUENCY');
I want to do this program using 'plot' command rather than 'bar' command. Its showing some errors such as >>too many input arguments.

采纳的回答

Matt J
Matt J 2013-3-16
编辑:Matt J 2013-3-16
You probably have a non-builtin function called 'bar.m' or 'plot.m' somewhere on your path. Execute
>>which bar(f,TL,'y')
>>which plot(f,TL,'y')
in the workspace of your code to find out.
  3 个评论
Image Analyst
Image Analyst 2013-3-16
编辑:Image Analyst 2013-3-16
Try
>>which -all plot
and show us the result in the command window. Next tell us the exact line of code you're executing, plus copy and paste the exact error message (don't paraphrase it, we want the exact message).

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by