Try to plot inductance as a function of g

3 Ansichten (letzte 30 Tage)
pedro oliveira
pedro oliveira am 24 Okt. 2021
Bearbeitet: dpb am 24 Okt. 2021
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 Kommentare
dpb
dpb am 24 Okt. 2021
Bearbeitet: dpb am 24 Okt. 2021
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 am 24 Okt. 2021
yes, you are correct, i tried something more beatiful but your answer its good, thank you

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Image Analyst
Image Analyst am 24 Okt. 2021
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';

Weitere Antworten (0)

Kategorien

Mehr zu Specifying Target for Graphics Output finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by