How do you perform generic value in MATLAB?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Please, I would like guidance regarding how to run a generic simulation with values I don't know__ eg __ez .
theta = fi([0,pi/4,pi/3,pi/2,(2*pi)/3,(3*pi)/4,pi])
er=sin(theta)*ex+cos(theta)*ez
eo=cos(theta)*ex-sin(theta)*ez
0 Commenti
Risposte (2)
John D'Errico
il 19 Dic 2021
Modificato: John D'Errico
il 19 Dic 2021
If you do not know those parameters, then you don't know them. What "simulation" would you run? What meaning does it have?
At best, you can use symbolic tools to leave them undefined, but still you have essentially nothing but an equation. You can evaluate things as a function of theta, but your result will have those parameters in there as unknowns.
theta = fi([0,pi/4,pi/3,pi/2,(2*pi)/3,(3*pi)/4,pi])
Your next problem is that sin and cos are not defined for that class.
whos theta
So while we can define ex and ez as symbolic parameters, at best you can convert them to doubles to use trig functions. But even then, you still are not running a simulation of any sort, because those parameters are undefined.
syms ex ez
dtheta = double(theta);
er=sin(dtheta)*ex+cos(dtheta)*ez
eo=cos(dtheta)*ex-sin(dtheta)*ez
But if you try to compute the sin and cos of theta itself, it fails:
er=sin(theta)*ex+cos(theta)*ez
Could you convert to double, then back fo an fi objects for the numerical values? I suppose, but that seems to miss the point of using fi in the first place, and I have a funny feeling that syms won't mix well with the fi objects.
0 Commenti
William Rose
il 19 Dic 2021
What is "fi()" in the first line of your code?
I am not sure I understand your question.
You can try different values for ex and ez. For each combination, you can plot er versus theta and eo versus theta.
If I remove the function "fi()" in line 1 of your code, and make guesses for the values of ex and for ez, and plot, then I get the following:
theta = [0,pi/4,pi/3,pi/2,(2*pi)/3,(3*pi)/4,pi];
ex=1; ez=0.5;
er=sin(theta)*ex+cos(theta)*ez;
eo=cos(theta)*ex-sin(theta)*ez;
plot(theta,er,'-r.',theta,eo,'-b.');
title('ex=1, ez=0.5');
legend('er','eo'); xlabel('theta');
Does that help?
2 Commenti
John D'Errico
il 19 Dic 2021
fi creates a fixed point object, from the fixed point toolbox.
theta = fi([0,pi/4,pi/3,pi/2,(2*pi)/3,(3*pi)/4,pi])
whos theta
help fi
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!