Issue with 3d plotting and writing to file
Afficher commentaires plus anciens
Hi, I'm doing a revision question for uni exams, and have the question - https://gyazo.com/4c0a0357bb2ffb6f2526637442e09a91
My issue is with the last part of the final question, my data points are much higher that required in the question. The code I've written is:
z = 1-x.^2 - y.^2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
subplot(3,1,1)
contour3(x,y,z)
subplot(3,1,2)
surf(x,y,z)
subplot(3,1,3)
mesh(x,y,z)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
header1 = 'x';
header2 = 'y';
header3 = 'z';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fid = fopen('mydata2.txt','w');
fprintf(fid,['\t', header1, '\t\t', header2, '\t\t', header3, '\n']);
for z = 1-x.^2 - y.^2
xx = -1:0.1:1;
yy = -2:0.1:2;
fprintf(fid, '%f %f %f \n',xx,yy,z);
end
fclose(fid);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Im pretty sure my loop is wrong or something to do with my axis? Any help is much appreciated!
Thanks
1 commentaire
KSSV
le 16 Mai 2018
YOu can write whole data into text file using dlmwrite, save....
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Graphics Object Properties dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!