필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
Harald von der Osten
Harald von der Osten 2022년 5월 28일
댓글: 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 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