Adding the stl file to the Matlab simulation

8 visualizaciones (últimos 30 días)
Aleyna
Aleyna el 16 de En. de 2024
Comentada: Star Strider el 29 de En. de 2024
I created a simulation in Matlab, but the satellite in the simulation looks like a normal rectangle. I want to replace that satellite with a satellite with a stl file. How can I write a code to add the stl file to the simulation?
When I run this code with the relevant places, I get the satellite output in the comments. But as I said, I want to replace it with stl file, how can I do it?
mass_spcrft = 2.6; %[kg] *Range: mass_spcrft > 0.0
dimnsnsX_spcrft = 0.1; %[m] *Range: dimnsnsX_spcrft > 0.0
dimnsnsY_spcrft = 0.1; %[m] *Range: dimnsnsY_spcrft > 0.0
dimnsnsZ_spcrft = 0.2; %[m] *Range: dimnsnsZ_spcrft > 0.0
inrtaTnsr_spcrft = [0.0108, 0, 0;
0, 0.0108, 0;
0, 0, 0.0043];
dimnsns_spcrft(1) = dimnsnsX_spcrft;
dimnsns_spcrft(2) = dimnsnsY_spcrft;
dimnsns_spcrft(3) = dimnsnsZ_spcrft;
clear dimnsnsX_spcrft;
clear dimnsnsY_spcrft;
clear dimnsnsZ_spcrft;
plot3([0, max(dimnsns_spcrft / 2) + 0.05], [0, 0], [0, 0], 'Color', 'w', 'LineWidth', 2, 'Clipping', 'off');
plot3([0, 0], [0, max(dimnsns_spcrft / 2) + 0.05], [0, 0], 'Color', 'w', 'LineWidth', 2, 'Clipping', 'off');
plot3([0, 0], [0, 0], [0, max(dimnsns_spcrft / 2) + 0.05], 'Color', 'w', 'LineWidth', 2, 'Clipping', 'off');
text(max(dimnsns_spcrft / 2) + 0.1, 0, 0, 'X_I', 'Color', 'w');
text(0, max(dimnsns_spcrft / 2) + 0.1, 0, 'Y_I', 'Color', 'w');
text(0, 0, max(dimnsns_spcrft / 2) + 0.1, 'Z_I', 'Color', 'w');
spcrftTrnsfrm = hgtransform;
set(spcrft(dimnsns_spcrft, true), 'Parent', spcrftTrnsfrm);
  1 comentario
Aleyna
Aleyna el 16 de En. de 2024
Note: simulation comes out as figure (not simulink)

Iniciar sesión para comentar.

Respuestas (1)

Star Strider
Star Strider el 16 de En. de 2024
It depends what the .stl file is.
The first step would be to use the stlread function to import it, and then use trisurf (or one of its friends) to plot it. After that, use the view function to orient it to the way you want it.
  2 comentarios
Aleyna
Aleyna el 29 de En. de 2024
I could not do the merging part of what you said with my own code anyway
Star Strider
Star Strider el 29 de En. de 2024
I cannot help with that because I do not have the .stl fille.
If you want to post it, use the zip function and then upload the .zip file here. If I do not see it posted in a few hours, I will delete my Answer.

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by