How to save the result of stlwrite to a specific directory chosen by the user
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Oraib Ghaith AlKheetanRojas
el 23 de En. de 2020
Comentada: marco mancini
el 20 de Mzo. de 2020
I am using the stlwrite to create an stl file out of a triangulted input, say for example I use f3 and v3 which are faces and verticies to create a triangulation and then convert that into stl. The stl saves in the same directory as code. I would like to have the option to ask the user of my code to chose a certain directory to save the file. how do I do that ?
TR = triangulation(f3,v3);
stlwrite(TR,'G.stl');
I am not sure I understand how uiputfile works.
0 comentarios
Respuesta aceptada
Stephen23
el 23 de En. de 2020
TR = ...
[F,P] = uiputfile('*.stl');
stlwrite(TR,fullfile(P,F))
2 comentarios
Rik
el 24 de En. de 2020
You should replace the last two lines of code with the lines indicated by Stephen. That should not result in the error you describe and will avoid two issues: overwriting the path function with a variable, and failing to support operating systems that have \ as the filesep.
Más respuestas (1)
marco mancini
el 16 de Mzo. de 2020
Hi,
could someone help me to solve this ERROR please?
I receive the following error using the stlwrite function:
Error using fileparts (line 37)
Input must be a row vector of characters or string scalar.
Error in stlwrite (line 70)
path = fileparts(filename);
Here my code:
X = randi(20,200,1)
Y = randi(20,200,1)
Z = randi(20,200,1)
% triangulate in xy
T = delaunay(X,Y)
% tet delaunay
tri = delaunayTriangulation(X,Y,Z)
% get surface faces and nodes
[F,P] = freeBoundary(tri);
% plot with trisurf
figure
trisurf(F,P(:,1),P(:,2),P(:,3),'FaceColor','red');
% now save
stlwrite(tri,'mytriangulation.stl');
thanks in advance,
Marco
12 comentarios
marco mancini
el 20 de Mzo. de 2020
Dear All,
I've just noted that the code above was generated with an old version of the the Sensor Array Analyzer.
I'd like to share the code generated with the latest version of the SAA and check with you if it is possibile to print the STL like Walter kindly showed with the previous method.
MAIN PROBLEM: When you run the code below, the figure get printed in STL, but the result is completely different from the figure you see in your editor (this issue was not happening in older version of SAA)
Here the code:
% MATLAB Code from Sensor Array Analyzer App
% Generated by MATLAB 9.7 and Phased Array System Toolbox 4.2
% Generated on 20-Mar-2020 19:09:54
% Create a uniform rectangular array
Array = phased.URA('Size',[4 4],...
'Lattice','Rectangular','ArrayNormal','x');
Array.ElementSpacing = [0.5 0.5];
% Calculate Row taper
rwind = ones(1,4).';
% Calculate Column taper
cwind = ones(1,4).';
% Calculate taper
taper = rwind*cwind.';
Array.Taper = taper.';
% Create an isotropic antenna element
Elem = phased.IsotropicAntennaElement;
Elem.FrequencyRange = [0 300000000];
Array.Element = Elem;
% Assign Steering Angles, Frequencies and Propagation Speed
SteeringAngles = [-30;0];
Frequency = 300000000;
PropagationSpeed = 299792458;
%Assign number of Phase shift quantization bits
PhaseShiftBits = 0;
% Create Figure
% Calculate Steering Weights
Freq3D = 300000000;
% Find the weights
w = zeros(getNumElements(Array), length(Frequency));
SteerVector = phased.SteeringVector('SensorArray',Array, 'PropagationSpeed', PropagationSpeed, 'NumPhaseShifterBits', PhaseShiftBits(1));
for idx = 1:length(Frequency)
w(:, idx) = step(SteerVector, Frequency(idx), SteeringAngles(:, idx));
end
% Plot 3d graph
format = 'polar';
% figure;
pattern(Array, Freq3D , 'PropagationSpeed', PropagationSpeed,...
'Type','directivity', 'CoordinateSystem', format,'weights', w(:,1));
% I ADDED THIS IN ORDER TO ALLOW THE PRINT OF THE STL
Model3D = pattern(Array, Freq3D , 'PropagationSpeed', PropagationSpeed,...
'Type','directivity', 'CoordinateSystem', format,'weights', w(:,1));
% export to STL
fvc = surf2patch(Model3D, 'triangles');
TR = triangulation(fvc.faces, fvc.vertices);
stlwrite(TR, 'STLM_apple.stl', 'text');
Thanks in advance for the contribution,
Ver también
Categorías
Más información sobre Model Import en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!