Why Matlab is not plotting anything in my figure?
Show older comments
[EDIT: 200110710 16:40 CDT - reformat - WDR]
I wrote a program and want to plot Zr as a line connecting dots for every whole degree from 0 to 360 degrees or 2*pi radians. I am not seeing anything when I run the following program:
%-------------------------------------------------------------------------------------------------------------------------------------
clear , clc ;
m = 0.25; % locus of the impedance “seen” by relays
Z = input('impedance is 0.1i or 0.025 + 0.1i '); % constant impedance
Ea = 1; % set Ea at 1 Per-Unit for simplicity
Eb = Ea / input('voltage behind Zeq = Zm ratio is 1.15 or 0.87 ');
Zm = m * Z + (1 - m) * Z; % equivalent impedance
d = 0;
increment = pi / 180;
end_count = 2 * pi;
for d = 0: increment : end_count;
d; % values of d in radians
I = ( Ea * cos(d) + Ea * 1i * sin(d) - Eb ) / Z;
% current of the circuit
E = ( 1 - m ) * (Ea * cos(d) + Ea * sin(d) * 1i + m * Eb);
%Voltage seen by relay
Zr = E / I; % impedance seen by the relays at m
r = abs(Zr);
the = angle(Zr);
end
figure ( 1 );
set (gca, 'FontSize', 12)
whitebg('white')
polar (r, the, 'red'), grid on
xlabel ('Impedance, Zr, Seen By Relay [Per-Unit]','FontSize',14);
ylabel ('Polar Coordinates / Compass Plot','FontSize',14);
Answers (1)
Walter Roberson
on 10 Jul 2011
0 votes
Each time through the loop, you are overwriting "r" and "the", so at the end of the loop they have only scalar values and only a single point is being plotted.
You should consider vectorizing your loop, or you should learn how to use arrays and loop indices.
4 Comments
Daniel
on 11 Jul 2011
Naresh
on 11 Jul 2011
n=1;
for d = 0: increment : end_count;
d; % values of d in radians
I = ( Ea * cos(d) + Ea * 1i * sin(d) - Eb ) / Z;
% current of the circuit
E = ( 1 - m ) * (Ea * cos(d) + Ea * sin(d) * 1i + m * Eb);
%Voltage seen by relay
Zr = E / I; % impedance seen by the relays at m
r(n) = abs(Zr);
the(n) = angle(Zr);
n=n+1;
end
%work for you?
Walter Roberson
on 11 Jul 2011
d = 0: increment : end_count;
I = ( Ea * cos(d) + Ea * 1i * sin(d) - Eb ) / Z;
E = ( 1 - m ) * (Ea * cos(d) + Ea * sin(d) * 1i + m * Eb);
Zr = E ./ I;
r = abs(Zr);
the = angle(Zr);
Daniel
on 11 Jul 2011
Categories
Find more on Trigonometry 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!