How to save the result of stlwrite to a specific directory chosen by the user
2 ビュー (過去 30 日間)
古いコメントを表示
Oraib Ghaith AlKheetanRojas
2020 年 1 月 23 日
コメント済み: marco mancini
2020 年 3 月 20 日
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 件のコメント
採用された回答
Stephen23
2020 年 1 月 23 日
TR = ...
[F,P] = uiputfile('*.stl');
stlwrite(TR,fullfile(P,F))
2 件のコメント
Rik
2020 年 1 月 24 日
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.
その他の回答 (1 件)
marco mancini
2020 年 3 月 16 日
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 件のコメント
marco mancini
2020 年 3 月 20 日
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,
参考
カテゴリ
Help Center および File Exchange で Model Import についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!