Effacer les filtres
Effacer les filtres

Adding the stl file to the Matlab simulation

8 vues (au cours des 30 derniers jours)
Aleyna
Aleyna le 16 Jan 2024
Commenté : Star Strider le 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);
  1 commentaire
Aleyna
Aleyna le 16 Jan 2024
Note: simulation comes out as figure (not simulink)

Connectez-vous pour commenter.

Réponses (1)

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

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by