필터 지우기
필터 지우기

wrinting a ".str" file

조회 수: 3 (최근 30일)
Win Thomas Halim
Win Thomas Halim 2011년 4월 27일
hi there, just want to ask u a simple question here, so suppose i have x y and z matrix which i want to convert into a stream file. they consist of 100x1 data each. what matlab command do i need to use to convert them into a ".str" attribute and how do i use it? thank you very much

답변 (1개)

Alexandre Carvalho Leite
Alexandre Carvalho Leite 2011년 4월 27일
Write your data into a file, just like in the following function:
function [] = surf2obj(fileName,x,y,z)
%
% SURF2OBJ converts a surface into an OBJ file.
%
% SURF2OBJ(fname,X,Y,Z) where fname is the filename (without extension)
% used to generate the dxf file and X, Y and Z are matrix arguments
% of the MATLAB surface format.
%
% Example: Classical peak plots:
%
% [X,Y,Z] = peaks(3);
% surf2obj('sd.obj',X,Y,Z); % search the file sd.obj at the current MATLAB path
%
%
% Author: Alexandre Carvalho Leite (alexandrecvl@hotmail.com)
%
p=surf2patch(surf(x,y,z));
fid=fopen(fileName,'w+');
for v=1:size(p.vertices,1),
fprintf(fid,'v %f %f %f\n',p.vertices(v,1),p.vertices(v,2),p.vertices(v,3));
end
fprintf(fid,'\n');
for f=1:size(p.faces,1),
fprintf(fid,'f %d %d %d %d\n',p.faces(f,1),p.faces(f,2),p.faces(f,3),p.faces(f,4));
end
fclose(fid);
  댓글 수: 1
Win Thomas Halim
Win Thomas Halim 2011년 5월 4일
do i need to download surf2obj function? if yes where can i find it? i cant find it in the file exchange.
im new at matlab, sorry for this question.
thank you

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by