Try to plot inductance as a function of g

2 views (last 30 days)
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 Comments
dpb
dpb on 24 Oct 2021
Edited: dpb on 24 Oct 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 on 24 Oct 2021
yes, you are correct, i tried something more beatiful but your answer its good, thank you

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 24 Oct 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';

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!