coding equation to m file

hey everyone a friend of mine help me with an equation and it work fine just i try to change it a litle but im not able there is out put, R value and X. x axis here is R but i want to change it to X exaclt viceversa with what you are seein here
please help me with
%%% ====== input values =========
U = 12;
% R = 2; % change from R=0,1,2,3
L = [2200e-6; 2.9e-3; 3.8e-3]; % change from 0.0022 to 0.0045 in mH
frequency = 400; % in Hz, maybe 50Hz.
fi = pi/3;
Er = 8;
ksi = 0.1;
Xv = 2*pi*frequency*L; % ‘X’ is now vector ‘Xv’
r = [];
y = [];
Rv = 0:0.1:3; % ‘R’ is now vector ‘Rv’
figure
hold all
for k1 = 1:numel(Xv)
X = Xv(k1); % ‘X’ is an element of ‘Xv’ in each loop iteration
for k2 = 1:numel(Rv)
R = Rv(k2);
r(k1,k2) = R;
a = exp((R/X)*(pi/3));
k = R/X;
alfa = atan(X/R);
alfa1 = alfa*0.017;
output = -R*U*(1+a)^2*exp(-k*(fi-pi/3))/(3*X^2*(1+a^3))+Er*sin(fi-ksi-alfa1)/sqrt(R^2+X^2);
y(k1,k2) = output;
end
plot (r(k1,:), y(k1,:))
OutpLeg{k1} = sprintf('Output L = %.1f mH', L(k1)*1000);
end
hold off
legend(OutpLeg)
xlabel('R'), ylabel('output')
title('gragh R\_output')

Réponses (1)

moji abb
moji abb le 11 Oct 2019

0 votes

%%% ====== input values =========
U = 12;
% R = 2; % change from R=0,1,2,3
L = [2200e-6; 2.9e-3; 3.8e-3]; % change from 0.0022 to 0.0045 in mH
frequency = 400; % in Hz, maybe 50Hz.
fi = pi/3;
Er = 8;
ksi = 0.1;
Xv = 2*pi*frequency*L; % ‘X’ is now vector ‘Xv’
r = [];
y = [];
Rv = 0:0.1:3; % ‘R’ is now vector ‘Rv’
figure
hold all
for k1 = 1:numel(Xv)
X = Xv(k1); % ‘X’ is an element of ‘Xv’ in each loop iteration
for k2 = 1:numel(Rv)
R = Rv(k2);
r(k1,k2) = R;
a = exp((R/X)*(pi/3));
k = R/X;
alfa = atan(X/R);
alfa1 = alfa*0.017;
output = -R*U*(1+a)^2*exp(-k*(fi-pi/3))/(3*X^2*(1+a^3))+Er*sin(fi-ksi-alfa1)/sqrt(R^2+X^2);
y(k1,k2) = output;
end
plot (r(k1,:), y(k1,:))
OutpLeg{k1} = sprintf('Output L = %.1f mH', L(k1)*1000);
end
hold off
legend(OutpLeg)
xlabel('R'), ylabel('output')
title('gragh R\_output')

8 commentaires

darova
darova le 14 Oct 2019
What is the difference?
moji abb
moji abb le 14 Oct 2019
What I'm looking is to Chang plots in this code x axis is R value with difrent impedance I need same equation but vice versa x axis is impedance with difrent resistance value
darova
darova le 14 Oct 2019
What if just switch
% plot (r(k1,:), y(k1,:))
plot (y(k1,:), r(k1,:))
And change labels
ylabel('R'), xlabel('output')
moji abb
moji abb le 14 Oct 2019
thank you for respond not good enough to explain let me try again :
current plot is out put with 2 different value " l and R I JUST need to change setting for these two i point in attached file Y AXIS is output
Y AXIS IS value L " AND OUT PUT change with difrrent value of R1.jpg
darova
darova le 14 Oct 2019
Still unclear, can you please try again to explain?
moji abb
moji abb le 14 Oct 2019
sure i do my best
As you see in above code , I have an equation I need to find the out put of this equation with variable value of resistance and inductance , if you run the code you will see the Y AXIS IS OUT PUT AND X AXIS IS RESISTANCE , what I cant figure out is how to replace the place of resistance and inductance in plot. x axis is “R” but I should change it to “X” in simple language is I need to change the place of “R” AND “X” in plot
darova
darova le 14 Oct 2019
You mean letter? Label?
xlabel('X')
moji abb
moji abb le 14 Oct 2019
yes X label is inductance and other parameter with 3 difrent value is resistance

Connectez-vous pour commenter.

Catégories

En savoir plus sur Deep Learning Toolbox dans Centre d'aide et File Exchange

Question posée :

le 11 Oct 2019

Commenté :

le 14 Oct 2019

Community Treasure Hunt

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

Start Hunting!

Translated by