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

5 ビュー (過去 30 日間)
Harald von der Osten
Harald von der Osten 2022 年 5 月 28 日
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
Harald von der Osten 2022 年 5 月 28 日
ha!! It works ! Thank you very much for your help, dear KSSV

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting 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