Effacer les filtres
Effacer les filtres

how to export of a sub aera of an array to xyz?

2 vues (au cours des 30 derniers jours)
Harald von der Osten
Harald von der Osten le 28 Mai 2022
if I use:
F = scatteredInterpolant(x,y,z,'natural','none');
xv=linspace(min(x,[],'all'),max(x,[],'all'),(max(x)-min(x))/faktor);
yv=linspace(min(y,[],'all'),max(y,[],'all'),(max(y)-min(y))/faktor);
zg = F({xv,yv});
and want to export an area of this array:
A=xv(1600:1:2000);
B=yv(400:1:800);
C = F({A,B});
to an xyz file....how can I manage this?
This:
fid = fopen('vdo.txt','w') ;
fprintf(fid,'%f %f %f\n', A', B', C') ;
fclose(fid) ;
or that
xx = A(:) ;
yy = B(:) ;
zz = C(:) ;
P = [xx yy zz] ;
fid = fopen('cut.dat', 'wt');
fprintf(fid, [repmat('%f\t', 1, size(P,2)-1) '%f\n'],P.');
fclose(fid)
doesn't work...
Thanks a lot

Réponse acceptée

KSSV
KSSV le 28 Mai 2022
Modifié(e) : KSSV le 28 Mai 2022
xx = A(:) ;
yy = B(:) ;
zz = C(:) ;
P = [xx yy zz] ;
fid = fopen('test.txt','w')
fprintf(fid,'%f %f %f\n', P.') ;
fclose(fid)
  5 commentaires
KSSV
KSSV le 28 Mai 2022
In that case, obviously you will get error. Becuase your xx,yy is 401*1 and zz is 160801*1; which you cannot merge into a column matrix. Try this:
[A,B] = meshgrid(A,B) ;
xx = A(:) ;
yy = B(:) ;
zz = C(:) ;
P = [xx yy zz] ;
fid = fopen('test.txt','w')
fprintf(fid,'%f %f %f\n', P.') ;
fclose(fid)
Harald von der Osten
Harald von der Osten le 28 Mai 2022
ha!! It works ! Thank you very much for your help, dear KSSV

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Produits


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by