How to plot a function for each frequency value?
Ältere Kommentare anzeigen
Hello,
I am still relatively new to MATLAB. I am trying to plot a calculation result (specifically, developed torque versus slip) at each frequency, for each slip value. The calculations use two different ranges, both are given below:
Frequency varied from the value of 5 to 66 in steps of 10, which I have written in the array f = [5: 10 :66]
For each frequency value, slip is to be varied from values 1 to -0.4, with a step equal to 0.01. The array for this is s = [-0.4 : 0.01 : 1]
I have been trying to achieve this using nested for loops, but I am still having trouble. What I have so far is given below:
Any help or advice in how I can do this is much appreciated, thank you very much to all.
close all; clear all; clc;
Vn = 380; % constant value parameters
fn = 50;
P = 2;
Rs = 10;
Rr = 6.3;
Lls = 0.04;
Llr = 0.04;
Lm = 0.42;
s = [-0.4 : 0.01 : 1]; % slip for the inverter supplied machine
f = [5 : 10 : 66]; % frequency to be varied
Vsn = Vn / sqrt(3);
Vo = 5; % this is the applied voltage boost
c = Vsn - 5;
for i = length(f)
a = f/fn; % v/f control constant
Xls = 2*pi*a*fn*Lls; % stator reactance
Xlr = 2*pi*a*fn*Llr; % rotor reactance
Xm = 2*pi*a*fn*Lm; % magnetising reactance
w_sync = 2*pi*a*fn; % synchronous speed scaled to v/f control
V = Vo + c*a;
for j = length(s)
Zm = 1j*Xm; % magnetising branch impedance
Zr = Rr/s(i) + 1j*Xlr; % rotor impedance
Zin = Rs + 1j*Xls + Zm*Zr/(Zm+Zr); % input impedance
Is(i) = V/Zin; % stator current
Ir = Zm/(Zm+Zr) * Is(i); % rotor current
IR = abs(Ir); % absolute value of rotor current
Te(i) = P * 3/w_sync * Rr/s(i) * IR^2; % electromagentic torque
w_speed = (1-s(i))*w_sync; % speed of rotation
end
end
plot(s,Te)
Antworten (1)
Star Strider
am 1 Mär. 2016
You need to change these lines to go from 1:length( ... ):
for i = 1:length(f)
. . .
for j = 1:length(s)
and this actually needs to have two subscripts:
Te(i,j) = P * 3/w_sync * Rr/s(i) * IR^2; % electromagentic torque
Ideally, you could use meshgrid and vectorise your code to make it faster, but it seems a bit complicated for that so I will leave that as an option for you to explore.
Kategorien
Mehr zu MATLAB finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!