Using 3 dimensional array to 2d-plot????
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
I need to use this 3 arrays into 2 equations to 2d-plot
w=0:1:100;
mu4=0:0.01:1;
lam4=0:0.01:1;
the equation is given below
code for the above equation is given below
th1=cos(lam4*(pmr/2));
th2=cos((1+lam4)*(pmr/2));
th3=cos((lam4+mu4)*(pmr/2));
th4=sin(mu4*(pmr/2));
th5=sin(lam4*(pmr/2));
ki=((-w^(3+lam4))+(42.46*(w^(1+lam4)))+(100*w^(mu4+lam4)*th4))/(250*th5)
kp=(-1/(250*(w^lam4)*th1))*(((-w^(3+lam4))*th2)+((42.46*w^(1+lam4))*th2)...
-(15.88*(w^(2+lam4))*th1)+(106.2*(w^lam4)*th1)+(100*(w^(lam4+mu4))*th3)...
+250*ki)
all the three array need to used together into the equation and get plot as the graph given below
How can i use the 3 dimensional array to plot the graph above.. please help me or suggest me some hints.
Thank you.
Nitesh
0 Commenti
Risposte (2)
Star Strider
il 30 Set 2015
At the very least you need to vectorise your equations to get vectors of ‘ki’ and ‘kp’:
ki=((-w.^(3+lam4))+(42.46*(w.^(1+lam4)))+(100*w.^(mu4+lam4).*th4))./(250*th5);
kp=(-1./(250*(w.^lam4).*th1)).*(((-w.^(3+lam4)).*th2)+((42.46*w.^(1+lam4)).*th2)...
-(15.88*(w.^(2+lam4)).*th1)+(106.2*(w.^lam4).*th1)+(100*(w.^(lam4+mu4)).*th3)...
+250*ki);
You did not provide ‘pmr’, and the values for your variables (and your equations) will not give you the full loop in the image. I leave that to you to sort out.
4 Commenti
Star Strider
il 30 Set 2015
I have no idea why your code is not reproducing the 2D plot you posted. (I have no idea what you are even doing.) I vectorised your ‘kp’ and ‘ki’ assignments and got them to work.
I must leave it to you to be sure they — and the rest of your code — are otherwise correct.
arich82
il 30 Set 2015
Modificato: arich82
il 30 Set 2015
At the very least, you need to switch your i=i+1 and k=k+1 statements: you have k indexing the inner-most loop, and i indexing the outer-most, but the increments are swapped. You also need to change ki in you statement for kp to ki(i, j, k).
You might also want to try plotting using
plot(ki(:), kp(:), '.')
I'm not sure this is going to give you what you want. I'm pretty sure that a fair number of your roughly 1 million data points will be inf and NaN...
Consider the following, which should be equivalent:
n = 100;
omega = linspace(0, 100, n + 1);
mu = linspace(0, 1, n + 1);
lambda = linspace(0, 1, n + 1);
[Omega, Mu, Lambda] = ndgrid(omega, mu, lambda);
K_i = -(...
-(Omega.^(3 + Lambda)) + ...
42.46*(Omega.^(1 + Lambda)) + ...
100*(Omega.^(Lambda + Mu)).*sin(Mu*pi/2)...
)./(250*sin(Lambda*pi/2));
K_p = -(...
-(Omega.^(3 + Lambda)).*cos((1 + Lambda)*pi/2) + ...
42.46*(Omega.^(1 + Lambda)).*cos((1 + Lambda)*pi/2) + ...
-15.88*(Omega.^(2 + Lambda)).*cos(Lambda*pi/2) + ...
106.2*(Omega.^(Lambda)).*cos(Lambda*pi/2) + ...
100*(Omega.^(Lambda + Mu)).*cos((Lambda + Mu)*pi/2) + ...
250*K_i ...
)./(250*(Omega.^Lambda).*cos(Lambda*pi/2));
figure; plot(K_p(:), K_i(:), '.')
It would appear that you're trying to plot the stability regions for a PID controller. I'm not sure this is the best approach...
2 Commenti
arich82
il 30 Set 2015
Modificato: arich82
il 30 Set 2015
Looking more closely at your (updated) problem, the plot you show (Figure 5) that indicates that mu and lambda are fixed in the plot ( 1.15 and 0.9, respectively). I assume that means the plot in the figure is essentially a parametric plot as a function of omega.
However, it doesn't seem like fixing these values in the code above reproduces the plot, though I might have made a mistake...
arich82
il 30 Set 2015
Note: I appear to have made an error in my first post: the expression for K_i has a leading negative sign which shouldn't be there.
(This also invalidates the values for K_p, and both plots, but the comments about the inf and NaN, the parametric nature of the plot, and the suggested range for omega still stand.)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!