Hi guys I am trying to do animation using figure from two different loop in a code ( 2012version!)

6 visualizaciones (últimos 30 días)
I am using Video writer do animation with plot inside of for-loop. The code is such that there are two separate for loop in series.Each work on different data files so cannot combine. the plot are values at 2D plance co-ordinate with time changing. the vedio will show each figure from two loop- in same time synchronized.
Here is sample of code- part 2 of figure:
vidObj=VideoWriter('Movie2.avi');
vidObj.Quality=100;
vidObj.FrameRate=5;
open(vidObj);
figure, set(gcf,'color','white')
Z=peaks; surf(Z);
axis tight;
set(gcf,'nextplot','replacechildren','visible','off');
%Test data Loop for reacd timstep
for j=1:16 %length(tot)
filename = strcat('U:\Powertrain\B0000',num2str(j),'.txt'
delimiter = '\t';
startRow = 2;
formatSpec = '%f%f%f%f%[^\n\r]';
fileID = fopen(filename,'r');
dataArray = textscan(fileID, formatSpec, 'Delimiter', delimiter, 'EmptyValue' ,NaN,'HeaderLines' ,startRow-1, 'ReturnOnError', false);
fclose(fileID);
xtest = dataArray{:, 1};
ztest = dataArray{:, 2};
utest = dataArray{:, 3};
wtest = dataArray{:, 4};
clearvars filename delimiter startRow formatSpec fileID dataArray ans;
subplot(2,2,1)
quiver(xtest,ztest,utest,wtest,'color','blue','linewidth',0.5); % CFD output
hold on; title([Test Velocity vector at time =',num2str(t2),' CA'],'FontWeight','bold')
%plot for u at different z
z1=1
for k=1:4
subplot(2,2,2)
plot(xtest(z1:(z1+51)),utest(z1:(z1+51))-10*(k-1));
hold on; title(['PIV test speed (u) at time =',num2str(t2),' CA'],'FontWeight','bold')
z1=z1+51+k;
end
drawnow;
writeVideo(vidObj,getframe(gca));
hold off;
end
close(gcf)
close(vidObj);
Here is error for the set(gcf) part:
set(gcf, 'Units', 'Normalized', 'Outerposition', [0, 0, 1, 1]);
It shows error msg:
Error using set
Bad property value found
Object name: figure
Property name: 'Units'
  2 comentarios
Walter Roberson
Walter Roberson el 27 de Oct. de 2016
Odd, when I test with that exact line (copied from your posting) it works for me in R2012a on OS-X
Is that line of code after everything else from your posting? The line does not appear in context in your code ?
Walter Roberson
Walter Roberson el 27 de Oct. de 2016
You have not posted your actual code. Your posted code has bugs that would prevent it from running.
Line 11
filename = strcat('U:\Powertrain\B0000',num2str(j),'.txt'
needs a closing )
Line 25
hold on; title([Test Velocity vector at time =',num2str(t2),' CA'],'FontWeight','bold')
needs an opening '
hold on; title(['Test Velocity vector at time =',num2str(t2),' CA'],'FontWeight','bold')
I do not have your Powertrain\B0000*.txt files so I cannot run the code to see if there is some run-time problem.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Animation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by