Loops in Matlab + Multiple Plots
Show older comments
Hi, I'm new to MATLAB, I have a piece of code that is working that takes computed currents of linear antennas and plots them, it looks like: (each antenna is divided into M pieces)
I1=abs(I(M+1:end,1)); z1=z(M+1:end,1);
I2=abs(I(M+1:end,2)); z2=z(M+1:end,2);
I3=abs(I(M+1:end,3)); z3=z(M+1:end,3); etc.
figure; plot(z1,I1,'.'); figure; plot(z2,I2,'.'); etc.
What I want to do is automate this for an arbitrary number of antennas. I have had several trials of the sort:
for j=1:N
I_(j)=abs(I(M+1:end,j)); z_(j)=z(M+1:end,j);
end
..or, I_j, or I(j) .. but as it became clear, I need to understand first what's going on in this (M+1:end,1) statement, and why do I get errors when I try any of the trial codes above.
1st type of error, for I_(j) and I(j)
??? In an assignment A(I) = B, the number of elements in B and I must be the same.
Error in ==> VB_Array25 at 18 I_(j)=abs(I(M+1:end,j)); z_(j)=z(M+1:end,j);
2nd type is when I use I_j, it doesn't say anything about the for loop but when I try figure; plot(z_1,I_1,'.');
??? Undefined function or variable 'z_1'.
Error in ==> VB_Array25 at 29 figure; plot(z_1,I_1,'.');
Any help will be more than welcome. -----------------------------------------------------
What I basically want to do after this, is be able to make all plots of I(z) for an arbitrary number of antennas on one plot and I will appreciate any comments on this as well.
Accepted Answer
More Answers (0)
Categories
Find more on Analysis 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!