how to write a formula in matlab including different variation
Afficher commentaires plus anciens
hey guys im new in matlab i try to write a fourmula with some variation in matlab but as i said im so new here. could you please help me with
A= EXP^ (PI/3)* R/X
THATS A PART OF FORMULA here r has difrent value
Réponse acceptée
Plus de réponses (5)
moji abb
le 6 Oct 2019
0 votes
13 commentaires
Star Strider
le 6 Oct 2019
If this is the equation you want to use, first write it in MATLAB code.
Note that
is written as:
exp(-k.*(phi-pi/3))
After you write it and get it working to your satisfaction (I will help you with that), and supply the necessary values for the constants, we can use the appropriate function to find one or more of the root values. Consider using the Symbolic Math Toolbox as well for this if you have access to it.
moji abb
le 6 Oct 2019
Star Strider
le 6 Oct 2019
Please keep all discussions related to this thread here. That creates a continuous narrative for others to follow.
moji abb
le 6 Oct 2019
Star Strider
le 6 Oct 2019
That seems to be correct.
For best results, you need to vectorise it:
output = -R.*U.*(1+a).^2.*exp(-k.*(fi-pi./3))./(3.*X.^2.*(1+a.^3))+Er.*sin(fi-ksi-alfa)./sqrt(R.^2+X.^2);
Supply the necessary values and see if it produces the correct result.
moji abb
le 6 Oct 2019
Star Strider
le 6 Oct 2019
As always, my pleasure.
moji abb
le 8 Oct 2019
Star Strider
le 8 Oct 2019
I do not understand what ‘the other side is an angle’ means. The equation you posted has part of an equal sign on the left, and on the right equals 0.
moji abb
le 8 Oct 2019
Star Strider
le 8 Oct 2019
First, 2*pi/2-pi/2 = pi/2. That much, at least, is solved.
I could code that expression for you (although I have no idea if the variables are scalrs, vectors, or matrices, and whether they are real, imaginary, or complex, so I could not guarantee that it would be correct), however the point is for you to learn how to code it. I will of course help you if you have problems coding it.
moji abb
le 8 Oct 2019
Star Strider
le 8 Oct 2019
Again, my pleasure.
Please code the equation, and post the code back here. It would be helpful if you also include the values of the variables.
moji abb
le 10 Oct 2019
0 votes
2 commentaires
moji abb
le 10 Oct 2019
Star Strider
le 10 Oct 2019
I made a few small changes to get your code to run with different values of ‘X’ as well as different values of ‘R’. This involves adding a loop and changing some of the indexing.
Your code is otherwise essentially unchanged:
%%% ====== 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')
Experiment to get the result you want.
moji abb
le 10 Oct 2019
0 votes
7 commentaires
Star Strider
le 10 Oct 2019
That would be more difficult, because that would be a volume. It would be easy enough to calculate using a vector of values for ‘fi’, since you would just need to add another loop (and another index, probably ‘k3’). See the isosurface function if you want to experiment with that idea.
moji abb
le 10 Oct 2019
Star Strider
le 10 Oct 2019
Again, my pleasure!
moji abb
le 14 Oct 2019
Star Strider
le 14 Oct 2019
I do not completely understand what you want to do. I also do not udnerstand what your code is doing.
If you want the functions of inductance to be on the x-axis, just reverse the order of the plot arguments:
plot (y(k1,:), r(k1,:))
and change the axis labels.
moji abb
le 15 Oct 2019
Star Strider
le 15 Oct 2019
I am having a very difficult time understanding what you want to do.
Apparently, you need to re-arrange your equations for your dependent variable as a function of ‘L’ as the independent variable. The easiest way to do this is to use the Symbolic Math Toolbox.
I cannot do that for you because I do not understand your equations or what you want to do with them.
moji abb
le 11 Oct 2019
0 votes
Catégories
En savoir plus sur Symbolic Math Toolbox dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
