Adding the stl file to the Matlab simulation

4 views (last 30 days)
Aleyna
Aleyna on 16 Jan 2024
Commented: Star Strider on 29 Jan 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);

Answers (1)

Star Strider
Star Strider on 16 Jan 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 Comments
Aleyna
Aleyna on 29 Jan 2024
I could not do the merging part of what you said with my own code anyway
Star Strider
Star Strider on 29 Jan 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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!