coding equation to m file

2 次查看(过去 30 天)
moji abb
moji abb 2019-10-11
评论: moji abb 2019-10-14
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')

回答(1 个)

moji abb
moji abb 2019-10-11
%%% ====== 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 个评论
darova
darova 2019-10-14
You mean letter? Label?
xlabel('X')
moji abb
moji abb 2019-10-14
yes X label is inductance and other parameter with 3 difrent value is resistance

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by