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
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