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

5 次查看(过去 30 天)
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

采纳的回答

KSSV
KSSV 2022-5-28
编辑:KSSV 2022-5-28
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 个评论
KSSV
KSSV 2022-5-28
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
ha!! It works ! Thank you very much for your help, dear KSSV

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

标签

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by