how to pause mesh command?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
i want to plot 3d space using mesh and also i want the grid appear 1 by 1 until it create fully space. this is my actual command:
[X,Y]=meshgrid(0:2/10:2,0:2/10:2);
W=exp(X+Y);
mesh(X,Y,W);
for more understanding based on what i said, look at this command and watch how the point appear:
t = 0:0.1:10*pi;
r = linspace (0, 1, numel (t));
z = linspace (0, 1, numel (t));
figure
axis([-1 1 -1 1 0 1])
hold on
for ii=1:length(r)
plot3 (r(ii)*sin(t(ii)), r(ii)*cos(t(ii)), z(ii),'*');
pause (.001)
end
i hope someone can help me....
1 commentaire
Adam
le 11 Mai 2016
What is the problem exactly?
pause( 0.001 )
is such a short amount of time you may not actually see it pausing though.
Réponses (2)
Mike Garrity
le 11 Mai 2016
Modifié(e) : Mike Garrity
le 11 Mai 2016
As I explained in this post on the MATLAB Graphics blog, creating a separate graphics object for each data point doesn't scale well.
I would suggest an approach more like this:
[X,Y] = meshgrid(0:2/100:2,0:2/100:2);
W = exp(X+Y);
h = mesh(X(1:2,1:2),Y(1:2,1:2),W(1:2,1:2));
xlim([0 2])
ylim([0 2])
zlim([0 60])
for i=3:101
h.XData = X(1:i,1:i);
h.YData = Y(1:i,1:i);
h.ZData = W(1:i,1:i);
drawnow
end
0 commentaires
maya sara
le 17 Mai 2016
Modifié(e) : maya sara
le 17 Mai 2016
I work as a group member with Yah Sha. Here I want to ask how to continue from your command in order to get a full graph appear. Below I attach a full program of our project.
clear
no_fig=0;
for h=0:0.005:0.05
if (h==0)|(h==0.005)|(h==0.025)|(h==0.05)
flag=h;
while flag~=0
%initial value
m=2.0/h;
for i=1:m+1
U(i,1)=exp (h*(i-1));
U(1,i)=exp (h*(i-1));
Ua(i,1)=exp (h*((i-1)+(1-1)));
Ua(1,i)=exp (h*((1-1)+(i-1)));
end
average_error=0;
for i=1:m
for j=1:m
%analytical soln
Ua(i+1,j+1)=exp(h*(i+j));
U(i+1,j+1)= (-U(i,j)+U(i+1,j)+U(i,j+1)+...
(((h^2.0)/4.0)*(U(i,j)+U(i+1,j)+U(i,j+1))))/(1.0-(h^2.0)/4.0);
error(i+1,j+1)=abs (U(i+1,j+1)-Ua(i+1,j+1))/abs (Ua(i+1,j+1));
average_error=error (i+1,j+1)+average_error;
end
end
flag=0;
end
flag=h;
while flag~=0
fprintf ('\nH=%1.4f',h)
fprintf ('\nUa(0.25,0.25)=%2.7f, U(0.25,0.25)=%2.7f, error (0.25,0.25)=%2.7e',...
Ua(round ((0.25+h)/h),round ((0.25+h)/h)), U(round ((0.25+h)/h),round ((0.25+h)/h)),...
error(round((0.25+h)/h),round((0.25+h)/h)))
fprintf ('\nUa(0.5,0.5)=%2.7f, U(0.5,0.5)=%2.7f, error (0.5,0.5)=%2.7e',...
Ua(round ((0.5+h)/h),round ((0.5+h)/h)), U(round ((0.5+h)/h),round ((0.5+h)/h)),...
error(round((0.5+h)/h),round((0.5+h)/h)))
fprintf ('\nUa(0.75,0.75)=%2.7f, U(0.75,0.75)=%2.7f, error (0.75,0.75)=%2.7e',...
Ua(round ((0.75+h)/h),round ((0.75+h)/h)), U(round ((0.75+h)/h),round ((0.75+h)/h)),...
error(round((0.75+h)/h),round((0.75+h)/h)))
fprintf ('\nUa(1.0,1.0)=%2.7f, U(1.0,1.0)=%2.7f, error (1.0,1.0)=%2.7e',...
Ua(round ((1.0+h)/h),round ((1.0+h)/h)), U(round ((1.0+h)/h),round ((1.0+h)/h)),...
error(round((1.0+h)/h),round((1.0+h)/h)))
fprintf ('\nUa(1.25,1.25)=%2.7f, U(1.25,1.25)=%2.7f, error (1.25,1.25)=%2.7e',...
Ua(round ((1.25+h)/h),round ((1.25+h)/h)), U(round ((1.25+h)/h),round ((1.25+h)/h)),...
error(round((1.25+h)/h),round((1.25+h)/h)))
fprintf ('\nUa(1.5,1.5)=%2.7f, U(1.5,1.5)=%2.7f, error (1.5,1.5)=%2.7e',...
Ua(round ((1.5+h)/h),round ((1.5+h)/h)), U(round ((1.5+h)/h),round ((1.5+h)/h)),...
error(round((1.5+h)/h),round((1.5+h)/h)))
fprintf ('\nUa(1.75,1.75)=%2.7f, U(1.75,1.75)=%2.7f, error (1.75,1.75)=%2.7e',...
Ua(round ((1.75+h)/h),round ((1.75+h)/h)), U(round ((1.75+h)/h),round ((1.75+h)/h)),...
error(round((1.75+h)/h),round((1.75+h)/h)))
fprintf ('\nUa(2.0,2.0)=%2.7f, U(2.0,2.0)=%2.7f, error (2.0,2.0)=%2.7e',...
Ua(round ((2.0+h)/h),round ((2.0+h)/h)), U(round ((2.0+h)/h),round ((2.0+h)/h)),...
error(round((2.0+h)/h),round((2.0+h)/h)))
fprintf ('\n*********************************');
fprintf ('***********************************');
fprintf ('\n ' );
fprintf ( 'ERRORS' );
fprintf ( ' FOR AM METHOD (LINEAR) ');
fprintf ('\nh : %2.4f',h );
fprintf ('\n*********************************');
fprintf ('***********************************');
fprintf ('\n| | ');
fprintf ( ' X ');
fprintf ('\n| Y | 0.5 1.0 ');
fprintf ( ' 1.5 2.0 ');
fprintf ('\n| |****************************');
fprintf ('***********************************');
fprintf ('\n|0.5| %2.7e %2.7e %2.7e %2.7e',...
error(round((0.5+h)/h),round((0.5+h)/h)),error(round((0.5+h)/h),round((1+h)/h)),...
error(round((0.5+h)/h),round((1.5+h)/h)),error(round((0.5+h)/h),round((2+h)/h)));
fprintf ('\n|1.0| %2.7e %2.7e %2.7e %2.7e',...
error(round((1+h)/h),round((0.5+h)/h)),error(round((1+h)/h),round((1+h)/h)),...
error(round((1+h)/h),round((1.5+h)/h)),error(round((1+h)/h),round((2+h)/h)));
fprintf ('\n|1.5| %2.7e %2.7e %2.7e %2.7e',...
error(round((1.5+h)/h),round((0.5+h)/h)),error(round((1.5+h)/h),round((1+h)/h)),...
error(round((1.5+h)/h),round((1.5+h)/h)),error(round((1.5+h)/h),round((2+h)/h)));
fprintf ('\n|2.0| %2.7e %2.7e %2.7e %2.7e\n',...
error(round((2+h)/h),round((0.5+h)/h)),error(round((2+h)/h),round((1+h)/h)),...
error(round((2+h)/h),round((1.5+h)/h)),error(round((2+h)/h),round((2+h)/h)));
fprintf('\naverage error = %2.7e\n\n\n',(average_error)/(m^2.0));
flag=0;
end
no_fig=no_fig+1;
if h==0
%exact soln
figure(no_fig)
[X,Y]=meshgrid(0:2/10:2,0:2/10:2);
W=exp(X+Y);
mesh(X,Y,W)
elseif (h==0.25)|(h==0.5)
figure(no_fig)
[X,Y]=meshgrid(0:2/4:2,0:2/4:2);
W=U(1:m/4:m+1,1:m/4:m+1);
mesh(X,Y,W)
else
figure(no_fig)
[X,Y]=meshgrid(0:2/10:2,0:2/10:2);
W=U(1:m/10:m+1,1:m/10:m+1);
mesh(X,Y,W)
end
xlabel('x-axis')
ylabel('y-axis')
zlabel('z-axis')
title('Soln For Linear Problem Using AM Method')
end
end
0 commentaires
Voir également
Catégories
En savoir plus sur Line Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!