Try to plot inductance as a function of g
3 次查看(过去 30 天)
显示 更早的评论
I'm trying to plot a graph inside a loop for, because i have to increase g value then calculate L(inductance):
N=35;
Ac = 9*10^-4;
Ag=Ac;
lc = 30*10^-2;
ur = 70000;
u0 = 4*pi*10^-7;
x=0.0001:0.00001:0.001;
for g=0.0001:0.00001:0.001
Rc = (lc)/(ur*u0*Ac);
Rg = g/(u0*Ag);
Rtot = Rc+Rg;
L= N^2/Rtot;
plot(x,L,'-','LineWidth',2);
pause(.2)
end
But the popout of the plot show but nothing happen, can someone fix the code?
2 个评论
dpb
2021-10-24
编辑:dpb
2021-10-24
But L doesn't have any dependence at all on x, so what's the point in having it?
Maybe you're looking for
N=35;
Ac = 9*10^-4;
Ag=Ac;
lc = 30*10^-2;
ur = 70000;
u0 = 4*pi*10^-7;
Rc = (lc)/(ur*u0*Ac);
g=0.0001:0.00001:0.001;
Rg = g/(u0*Ag);
Rtot = Rc+Rg;
L= N^2/Rtot;
plot(g,L,'-','LineWidth',2);
???
采纳的回答
Image Analyst
2021-10-24
It seems like you want the drawing to be animated because you used pause(0.2) so try it this way:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format short g;
format compact;
fontSize = 16;
N=35;
Ac = 9*10^-4;
Ag=Ac;
lc = 30*10^-2;
ur = 70000;
u0 = 4*pi*10^-7;
x=0.0001:0.00001:0.001;
allg=0.0001:0.00001:0.001
% Animate the curve drawing.
for k = 1 : length(allg)
g(k) = allg(k);
Rc = (lc) / (ur*u0*Ac);
Rg = g(k) / (u0*Ag);
Rtot = Rc+Rg;
L(k) = N^2 / Rtot;
plot(x(1:k), L(1 : k),'b.-','LineWidth',2, 'MarkerSize', 17);
grid on;
title('L vs. x', 'FontSize', fontSize);
xlabel('x', 'FontSize', fontSize);
ylabel('L', 'FontSize', fontSize);
pause(.2)
end
g = gcf;
g.WindowState = 'maximized';
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!