Borrar filtros
Borrar filtros

wrinting a ".str" file

3 visualizaciones (últimos 30 días)
Win Thomas Halim
Win Thomas Halim el 27 de Abr. de 2011
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

Respuestas (1)

Alexandre Carvalho Leite
Alexandre Carvalho Leite el 27 de Abr. de 2011
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 comentario
Win Thomas Halim
Win Thomas Halim el 4 de Mayo de 2011
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

Iniciar sesión para comentar.

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by