I want to solve the equation within the loop and plot it, but it seems not work
1 view (last 30 days)
Show older comments
clear;
close all;
Ls = 75e-6;
Lr = 75e-6;
Lm = 2e-3;
rs = 20e-3;
rr = 20e-3;
Vbat = 400;
nph = 3;
B = 0.01;
Kload = 50e-7;
P = 4;%poles
for nr = 0:6000
wr = 2*pi/60*nr;
ns = 120*fe/P;
Vs_rms = Vbat/2/2^0.5;
syms fe;
Xms = fe*Lm;
Xls = fe*Ls;
Xlr = fe*Lr;
Vth = Xms*Vs_rms/(rs^2+(Xms+Xls)^2)^0.5;
rth = rs*(Xms/(Xms+Xls));
Xth = Xms*Xls/(Xms+Xls);
we = 2/P*2*pi*fe;
s = (we-wr)/we;
eqn = nph*Vth^2*rr/(s*we)/((rth+rr/s)^2+(Xth+Xlr)^2)== Kload*nr^2+B*wr; %Te
[solfe] = solve(eqn,fe);
fe = double(solfe);
Te = Kload*nr^2+B*wr
plot (wr, Te);
plot (we, Te);
grid on;
hold on;
xlabel('rad/s');
ylabel('T');
legend;
end
0 Comments
Accepted Answer
Jon
on 16 Apr 2019
Maybe you can explain further what you mean by it doesn't seem to work. What is it doing that you don't want it to do or what isn't it doing that you want it to do.
In any case, without getting into all of the details of your program I can see two possible issues.
I see that you issue two plot commands one right after the other. In this case the second plot will overwrite the first. You should call the figure function between the calls to plot to open a new figure. So it should look something like this instead
plot (wr, Te);
figure
plot (we, Te);
Also, it doesn't look like you "hold on" is place correctly. It looks like this would make a curve and keep it for every loop iteration, so 6000 curves. Is that what you intended?
Finally, for when you want to include code it is a good idea to use the code button in the toolbar where you edit your question. That way it is nicely formatted and easier for other people to view and use.
2 Comments
Walter Roberson
on 16 Apr 2019
Perhaps it would make sense to use vpasolve(), and give it a range of [0 inf] so that it does not give imaginary or negative results.
More Answers (0)
See Also
Categories
Find more on Subplots 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!