From: Rick T on 18 Jun 2010 14:32 Greetings All I have a 2D and 3D animation that I would like help fixing and syncing. 1st question is that the 3D animation is twice as fast as the 2D animation how can I make it so they are the same speed? (notice the number in degrees) 2nd question How can I speed up the animation so it's doesn't look like it's in slow motion but a smooth flow? 3rd question the 3D animation is moving at an angle instead of just going from right or left and up and down it's going up and down and at an angle (looks to be about 45 degrees off instead of just going from right to left or left to right and up and down) Code below %% Variables clear;clc; tic VERTOFFmain_1=0; VERTOFFaad_1=0;VERTOFFabd_1=0; AMPmain_1=0; AMPaaa_1=1;AMPaba_1=1; FREQmain_1=1; FREQaab_1=0;FREQabb_1=0; PHASEmain_1=deg2rad(0);PHASEmain2_1=deg2rad(0); PHASEaac_1=deg2rad(0);PHASEabc_1=deg2rad(0); % deg =0; % phase=deg*pi/180; t=linspace(0,1,20); %t2=linspace(0,2*pi,length(t)); wt=2*pi*t; %% %% Creating number sequence for Phase array h1=deg2rad(linspace(0,360,length(t))); %h2=deg2rad(linspace(360,0,length(t))); h2=flipdim(h1,2); %flip array 1 is up/down 2 is left/right phaseStartOffset=deg2rad(0); %% Equations e_1(x) = k1 + a1 sin(d1 (x - h1)) k1=0;k2=0; a1=1;a2=1; d1=1;d2=1; %h1=0;h2=0; y1=k1+a1*sin(d1*(2*pi-(h1))); %check animation to see where to put next variable % y1=y1/max(y1)*.8; %limits amplitude to under 1 y2=k2+a2*sin(d2*(2*pi-(h2-phaseStartOffset))); %check animation to see where to put next variable % y2=y2/max(y2)*.8; %limits amplitude to under 1 % freqrps=0; %% Animation of signal count=1; reruns=1; % number of times movie is to play fps=10; % frames per second %nframes = 12; % number of frames in the movie %Frames = moviein(nframes); % initialize the matrix 'Frames' %% 2D Animation % for freqrps=0:.05:2*pi % y1_ani=k1+a1*sin(d1*(2*pi-(h1+freqrps))); % y2_ani=k2+a2*sin(d2*(2*pi-(h2+freqrps)-phaseStartOffset)); % yt_ani=y1_ani+y2_ani; % %yt_ani=yt_ani/ytMax*0.5; %don't use yet % plot(t,y1,t,y2) % axis([0, 1, -2, 2]); %.5 to increase axis % s1=sprintf('y(h1)=sin(%.2f h1)',freqrps); % text(.1,1.5,s1) % %axis([0, 1, ytMin-.5, ytMax+.5]); %.5 to increase axis % M(count)=getframe; % count=count+1; % end; % %2D/3D Animated Plot ani_loops=2*pi; %2*pi = 6.28 which equals 1 loop for freqrps=0:.05:ani_loops y1_ani=k1+a1*sin(d1*(2*pi-(h1+freqrps))); y2_ani=k2+a2*sin(d2*(2*pi-(h2+freqrps)-phaseStartOffset)); yt_ani=y1_ani+y2_ani; subplot(3,2,1);plot(t,y1_ani);axis([0, 1, -2, 2]); %title(['Degrees ',num2str(freqrps*180/3.1415),'''']) subplot(3,2,3);plot(t,y2_ani);axis([0, 1, -2, 2]); title({'2D Standing Waves ';[' Degrees ',num2str(freqrps*180/ pi),'''']}) subplot(3,2,5);plot(t,yt_ani);axis([0, 1, -2, 2]); %plot(t,y1_ani,t,y2_ani,t,yt_ani); %axis([0, 1, -2, 2]); %.5 to increase axis %[X1,Y1] = meshgrid(linspace(0,2*pi,50),linspace(0,pi,50)); [h1x,h1y] = meshgrid(h1,h1); [h2x,h2y] = meshgrid(h2,h2); zh1a=k1+a1*sin(d1*(2*pi-(h1x+(freqrps)))).*(k1+a1*cos(d1*(2*pi-(h1y +freqrps)))); zh1b=k1+a1*sin(d1*(2*pi-(h2x+freqrps)- phaseStartOffset)).*(k1+a1*cos(d1*(2*pi-(h2y+freqrps)- phaseStartOffset))); zh2a=k1+a1*sin(d1*(2*pi-(h1x+freqrps))).*(k1+a1*cos(d1*(2*pi-(h1y +freqrps)))); zh2b=k1+a1*sin(d1*(2*pi-(h2x+freqrps)- phaseStartOffset)).*(k1+a1*cos(d1*(2*pi-(h2y+freqrps)- phaseStartOffset))); zt=(zh1a+zh1b); subplot(3,2,2);surfc(h1x,h1y,zh1a);view([-30 30]); subplot(3,2,4);surfc(h2x,h2y,zh2a);view(-30,30); title({'3D Standing Waves ';[' Degrees ',num2str(freqrps*180/ pi*2),'''']}) subplot(3,2,6);surfc(h1x,h1y,zt);view(-30,30); %axis([0, 8, 0, 10 -2,2]);view(5,30); axis([0, 8, 0, 10 -2,2]);view(53,24); %meshc(X,Y,Z2); xlabel('x'); ylabel('y'); zlabel('z'); M(count)=getframe; count=count+1; end; %%%movie(M,reruns,fps) don't use tia sal22
|
Pages: 1 Prev: FM demodulation Next: finding intersection coordinate of straingt line & curve |