Try to plot inductance as a function of g

2 ビュー (過去 30 日間)
pedro oliveira
pedro oliveira 2021 年 10 月 24 日
編集済み: dpb 2021 年 10 月 24 日
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
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);
???
pedro oliveira
pedro oliveira 2021 年 10 月 24 日
yes, you are correct, i tried something more beatiful but your answer its good, thank you

サインインしてコメントする。

採用された回答

Image Analyst
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';
  1 件のコメント
pedro oliveira
pedro oliveira 2021 年 10 月 24 日
thank you, thats a good ans for what i wanted

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpecifying Target for Graphics Output についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by