Verfasst am: 10.04.2011, 13:57
Titel: animation durch for-schleife
hallo:)
hätte da ne einfache frage
und zwar: ich brauch eine animation mit einer for schleife..
wie komme ich von dieser ausgangsposition
Code:
% Erster Arm --> x1,x2 und y1,y2 stehen f�r Punkt P
x1=0; x2=60*cos(2);
y1=0; y2=60*sin(2);
x=[x1 x2]; y=[y1 y2];
plot(x,y,'LineWidth',2) hold on
% Zweiter Arm--> x2,x3 und y2,y3 sind Koordinaten f�r Punkt Q
x2=60*cos(2); x3=60*cos(2)-60*cos(2+0.7);
y2=60*sin(2); y3=60*sin(2)-60*sin(2+0.7);
x=[x2 x3]; y=[y2 y3];
plot(x,y, 'LineWidth', 2) hold on
%Erster Arm --> x1,x2 und y1,y2 stehen f�r Punkt P
x1=0; x2=60*cos(1.4);
y1=0; y2=60*sin(1.4);
x=[x1 x2]; y=[y1 y2];
plot(x,y,'LineWidth',2) hold on
% Zweiter Arm--> x2,x3 und y2,y3 sind Koordinaten f�r Punkt Q
x2=60*cos(1.4); x3=60*cos(1.4)-60*cos(1.4+1.4);
y2=60*sin(1.4); y3=60*sin(1.4)-60*sin(1.4+1.4);
x=[x2 x3]; y=[y2 y3];
plot(x,y, 'LineWidth', 2) hold on
ok hab gedacht es funktioniert so..
aber leider bewegt sich gar nichts wenn ich den quellcode ausführen lasse :S
ich bekomm das einfach nicht gebacken:D
die aufgabenstellung war die 4 postionen der arme darzustellen..
und hab dann auch ne animation hinbekommen..allerdings ohne forschleife..
kann mir das jemand genau erklären? :S
%Boden
plot([-2080], [00],'k', 'LineWidth', 4) hold on
% Erster Arm --> x1,x2 und y1,y2 stehen f�r Punkt P
x1=0; x2=60*cos(1.847);
y1=0; y2=60*sin(1.847);
x=[x1 x2]; y=[y1 y2];
plot(x,y,'LineWidth',2) hold on
% Zweiter Arm--> x2,x3 und y2,y3 sind Koordinaten f�r Punkt Q
x2=60*cos(1.847); x3=60*cos(1.847)-60*cos(1.847+0.34787);
y2=60*sin(1.847); y3=60*sin(1.847)-60*sin(1.847+0.34787);
x=[x2 x3]; y=[y2 y3];
plot(x,y, 'LineWidth', 2) hold on
% Kugel Einheitskreis
r=5; x=20; y=(60*sin(1.847)-60*sin(1.847+0.34787))/2;
n=100;
phi=linspace(0,2*pi,n+1);
fill(x+r*cos(phi),y+r*sin(phi),'r') hold on
% Viereck fill([45555545],[002525],'g');
plot([45555545],[002525],'k','LineWidth',1);
hold on
% Kreisb�gen f�r Winkel aplha und beta % alpha
r=5; x=0; y=0;
n=100;
alpha1=pi/25; alpha2=5*pi/8;
phi=linspace(alpha1,alpha2,n+1);
plot(x+r*cos(phi),y+r*sin(phi),'k') text(0.5,2.5,'\alpha') hold on
% beta
r=10.5; x=60*cos(1.847); y=60*sin(1.847);
n=100;
alpha1=12.5*pi/8; alpha2=13.8*pi/8;
phi=linspace(alpha1,alpha2,n+1);
plot(x+r*cos(phi),y+r*sin(phi),'k') text(60*cos(1.847)+2,60*sin(1.847)-6,'\beta') hold on
% Erster Arm --> x1,x2 und y1,y2 stehen f�r Punkt P
x1=0; x2=60*cos(2);
y1=0; y2=60*sin(2);
x=[x1 x2]; y=[y1 y2];
plot(x,y,'LineWidth',2) hold on
% Zweiter Arm--> x2,x3 und y2,y3 sind Koordinaten f�r Punkt Q
x2=60*cos(2); x3=60*cos(2)-60*cos(2+0.7);
y2=60*sin(2); y3=60*sin(2)-60*sin(2+0.7);
x=[x2 x3]; y=[y2 y3];
plot(x,y, 'LineWidth', 2) hold on
% Kugel Einheitskreis
r=5; x=60*cos(2)-60*cos(2+0.7); y=(60*sin(2)-60*sin(2+0.7)-5);
n=100;
phi=linspace(0,2*pi,n+1);
fill(x+r*cos(phi),y+r*sin(phi),'r') hold on
% Kreisb�gen f�r Winkel aplha und beta % alpha
r=5; x=0; y=0;
n=100;
alpha1=pi/25; alpha2=5*pi/8;
phi=linspace(alpha1,alpha2,n+1);
plot(x+r*cos(phi),y+r*sin(phi),'k') text(0.5,2.5,'\alpha') hold on
% beta
r=8; x=60*cos(2); y=60*sin(2);
n=100;
alpha1=13*pi/8; alpha2=15*pi/8;
phi=linspace(alpha1,alpha2,n+1);
plot(x+r*cos(phi),y+r*sin(phi),'k') text(60*cos(1.847)-5,60*sin(1.847)-7,'\beta') hold on
%Erster Arm --> x1,x2 und y1,y2 stehen f�r Punkt P
x1=0; x2=60*cos(1.4);
y1=0; y2=60*sin(1.4);
x=[x1 x2]; y=[y1 y2];
plot(x,y,'LineWidth',2) hold on
% Zweiter Arm--> x2,x3 und y2,y3 sind Koordinaten f�r Punkt Q
x2=60*cos(1.4); x3=60*cos(1.4)-60*cos(1.4+1.4);
y2=60*sin(1.4); y3=60*sin(1.4)-60*sin(1.4+1.4);
x=[x2 x3]; y=[y2 y3];
plot(x,y, 'LineWidth', 2) hold on
% Kugel Einheitskreis
r=5; x=60*cos(1.4)-60*cos(1.4+1.4); y=(60*sin(1.4)-60*sin(1.4+1.4))-5;
n=100;
phi=linspace(0,2*pi,n+1);
fill(x+r*cos(phi),y+r*sin(phi),'r') hold on
% Kreisb�gen f�r Winkel aplha und beta % alpha
r=5; x=0; y=0;
n=100;
alpha1=pi/25; alpha2=5.5*pi/12;
phi=linspace(alpha1,alpha2,n+1);
plot(x+r*cos(phi),y+r*sin(phi),'k') text(0.5,2.5,'\alpha') hold on
% beta
r=8; x=60*cos(1.4); y=60*sin(1.4);
n=100;
alpha1=11.5*pi/8; alpha2=15*pi/8;
phi=linspace(alpha1,alpha2,n+1);
plot(x+r*cos(phi),y+r*sin(phi),'k') text(60*cos(1.4)+1.5,60*sin(1.4)-3,'\beta') hold on
%Viertes Bild mit Winkel alpha=0.95844 , beta=1.4734
%Erster Arm --> x1,x2 und y1,y2 stehen f�r Punkt P
x1=0; x2=60*cos(0.95844);
y1=0; y2=60*sin(0.95844);
x=[x1 x2]; y=[y1 y2];
plot(x,y,'LineWidth',2) hold on
% Zweiter Arm--> x2,x3 und y2,y3 sind Koordinaten f�r Punkt Q
x2=60*cos(0.95844); x3=60*cos(0.95844)-60*cos(0.95844+1.4734);
y2=60*sin(0.95844); y3=60*sin(0.95844)-60*sin(0.95844+1.4734);
x=[x2 x3]; y=[y2 y3];
plot(x,y, 'LineWidth', 2) hold on
% Kugel Einheitskreis
r=5; x=60*cos(0.95844)-60*cos(0.95844+1.4734); y=(60*sin(0.95844)-60*sin(0.95844+1.4734))-5;
n=100;
phi=linspace(0,2*pi,n+1);
fill(x+r*cos(phi),y+r*sin(phi),'r') hold on
% Kreisb�gen f�r Winkel aplha und beta % alpha
r=8; x=0; y=0;
n=100;
alpha1=pi/15; alpha2=4*pi/12;
phi=linspace(alpha1,alpha2,n+1);
plot(x+r*cos(phi),y+r*sin(phi),'k') text(2.5,2.5,'\alpha') hold on
% beta
r=8; x=60*cos(0.95844); y=60*sin(0.95844);
n=100;
alpha1=10.5*pi/8; alpha2=14*pi/8;
phi=linspace(alpha1,alpha2,n+1);
plot(x+r*cos(phi),y+r*sin(phi),'k') text(60*cos(0.95844),60*sin(0.95844)-3,'\beta') hold on
% Erster Arm --> x1,x2 und y1,y2 stehen f�r Punkt P
x1=0; x2=60*cos(1.847);
y1=0; y2=60*sin(1.847);
x=[x1 x2]; y=[y1 y2];
plot(x,y,'LineWidth',2) hold on
% Zweiter Arm--> x2,x3 und y2,y3 sind Koordinaten f�r Punkt Q
x2=60*cos(1.847); x3=60*cos(1.847)-60*cos(1.847+0.34787);
y2=60*sin(1.847); y3=60*sin(1.847)-60*sin(1.847+0.34787);
x=[x2 x3]; y=[y2 y3];
plot(x,y, 'LineWidth', 2) hold on
% Viereck fill([45555545],[002525],'g');
plot([45555545],[002525],'k','LineWidth',1);
hold on
%Boden
plot([-2080], [00],'k', 'LineWidth', 4) hold on
% Erster Arm --> x1,x2 und y1,y2 stehen f�r Punkt P for i = 1.847:2
x1=0; x2=60*cos(i);
y1=0; y2=60*sin(i);
x=[x1 x2]; y=[y1 y2];
plot(x,y,'LineWidth',2) axis equal
Du kannst Beiträge in dieses Forum schreiben. Du kannst auf Beiträge in diesem Forum antworten. Du kannst deine Beiträge in diesem Forum nicht bearbeiten. Du kannst deine Beiträge in diesem Forum nicht löschen. Du kannst an Umfragen in diesem Forum nicht mitmachen. Du kannst Dateien in diesem Forum posten Du kannst Dateien in diesem Forum herunterladen
MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.