Changing from 'bar' command to 'plot' command.
1 view (last 30 days)
Show older comments
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.
0 Comments
Accepted Answer
Matt J
on 16 Mar 2013
Edited: Matt J
on 16 Mar 2013
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 Comments
Image Analyst
on 16 Mar 2013
Edited: Image Analyst
on 16 Mar 2013
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).
More Answers (0)
See Also
Categories
Find more on Annotations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!