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!