Filter löschen
Filter löschen

wrinting a ".str" file

3 Ansichten (letzte 30 Tage)
Win Thomas Halim
Win Thomas Halim am 27 Apr. 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

Antworten (1)

Alexandre Carvalho Leite
Alexandre Carvalho Leite am 27 Apr. 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 Kommentar
Win Thomas Halim
Win Thomas Halim am 4 Mai 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

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by