Azzera filtri
Azzera filtri

Animated Vectors Plot with data coming from Simulink (WITH EXPLAINING IMAGES)

3 visualizzazioni (ultimi 30 giorni)
Hallo, I'm getting mad to understand how to do something like this : (WATCH) " http://www.energyreply.it/teoria.html " There is only one animated image in the page, well, I need to know how to do it.
Actually I only need to know how to plot animated vectors coming from a Simulink model. All the rest is easy.
My Simulink model produce two separate signals: For exemple sin(x) and cos(x) when X are a stream of values coming from a slope function from 0 to 2*pi.
How can I plot a vector (not necessarily starting from the origin of axis) and see it turning ? When I say a VECTOR I MEAN AN ARROW ! not a simple point!
I hope to be able to see an animation of an arrow that turns around a custom defined point.
And don't forget to explain how to set the speed of the animation! Sometimes happens that animation appears only for half a second!
Does anyone know how to do this?
Pleeeeese help me! I'M LOOSING THE TRUST IN MYSELF :-(

Risposta accettata

Kaustubha Govind
Kaustubha Govind il 19 Lug 2011
The webpage that you pointed to uses Adobe Flash to achieve with the animation - I don't know of a way to generate Adobe Flash files directly from MATLAB data.
However, you should be able to create an animated GIFs from MATLAB plots. See this File Exchange submission: Animated GIF
You first need to export your Simulink outputs to the MATLAB workspace, and then use MATLAB plotting functions.
  2 Commenti
Graziano Ullucci
Graziano Ullucci il 19 Lug 2011
I'm trying to solve the problem by following your instructions. I really hoped that they are sufficient. Thanks for your help. However I still hope that someone will post a small example.
Graziano Ullucci
Graziano Ullucci il 28 Lug 2011
I've been able to do this:
for t=1:360
hold on
corda=0.3;
r=0.3;
a=0;
b=0.2;
c=0.2;
d=0;
e=0.2;
f=0.2;
g=-0.2;
h=-0.2;
z=(-1*(r+corda));
x=(r+corda);
axis([z x z x]);
Dpercent=[0.00,1.25,2.50,5.00,7.50,10.00,15.00,20.00,30.00,40.00,50.00,60.00,70.00,80.00,90.00,95.00,100.00,100.00,95.00,90.00,80.00,70.00,60.00,50.00,40.00,30.00,20.00,15.00,10.00,7.50,5.00,2.50,1.25,0.00];
x=corda.*((Dpercent-25.00)./100);
Ypercent=[0.00,2.37,3.27,4.44,5.25,5.85,6.68,7.17,7.50,7.25,6.62,5.70,4.58,3.28,1.81,1.01,0.16,-0.16,-1.01,-1.81,-3.28,-4.58,-5.70,-6.62,-7.25,-7.50,-7.17,-6.68,-5.85,-5.25,-4.44,-3.27,-2.37,0.00];
y=r+(corda.*(Ypercent./100));
X=x.*cos(t*(2*pi)/360)-y.*sin(t*(2*pi)/360);
Y=x.*sin(t*(2*pi)/360)+y.*cos(t*(2*pi)/360);
plot(X,Y);
r1=0.*cos(t*(2*pi)/360)-r.*sin(t*(2*pi)/360);
r2=0.*sin(t*(2*pi)/360)+r.*cos(t*(2*pi)/360);
R1=[0,r1];
R2=[0,r2];
plot(R1,R2);
quiver(r1,r2,a,b);
quiver(r1,r2,c,d);
quiver(r1,r2,e,f);
quiver(r1,r2,g,h);
M(t)=getframe
clf
end
movie(M);
Now I need to esport simulation data from simulink to matlab's workspace.
I used the block "simout to workspace"
I tryed to specify that I need a simple ARRAY variable type but it LOVES to SAVE MY DATA AS:
simout <1x1x64 double>
I need a simple array made of 64 elements with my numerical value inside. My model is costant time division made so I don't need time information.
(Anyway could be usefull in tre future to know wow to obtain a two rows 64 coloumn matrix with a row for time and a row for values)
I don't know how to build a simple array from my
simout <1x1x64 double>
For exemple to use it for defining the vectors component in the animation.
I need a simple exemple of script in which you take an array made like myne (simout <1x1x64 double> coming from "simout to workspace" setted like "ARRAY" type) and use it to plot it:
Wrong exemple:
A=[1:64];
plot(A,simout);
That exemple doesn't work....
How to make it run?
Does anybody knows?
thankyou.

Accedi per commentare.

Più risposte (2)

Graziano Ullucci
Graziano Ullucci il 29 Lug 2011
This script work but, anybody knows a faster way tho download the values ftom simout into A?
A=[simout(:,:,1),simout(:,:,2),simout(:,:,3),simout(:,:,4) ------------ simout(:,:,500]; B=[1:500]; Plot(B,A);
Probably it is not very difficult someone can help me?

Graziano Ullucci
Graziano Ullucci il 29 Lug 2011
For exemple this doesn't work
B=[1:500]; A=[VwrX(:,:,B)]; plot(B,A);
It is faster but don't work. suggestions?

Community Treasure Hunt

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

Start Hunting!

Translated by