How to access values in struct from another script?
5 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Laurel Castillo
le 1 Déc 2018
Modifié(e) : Stephen23
le 1 Déc 2018
Hi all,
So I have a script as below with some data in struct.
For example, I want to access the value 1.2 in the struct, when I am working on another script (e.g. CAL.m) for manipulation. What code should I use?
If the 1.2 is in a matrix named DH in the CAL.m, I can access it with DH(1,4) in CAL.m
But now the DH is a struct and located in ArmModel.m, how can I acess its values in CAL.m?
The purpose here is to store some data in the script ArmModel.m, and then access the data from another script CAL.m. So I can plug other dataset maybe ArmModel2.m, ArmModel3.m...... into CAL.m later.
Thanks!
function m = ArmModel()
l_RCC = 0.4318;
l_tool = 0.4162;
l_pitch2yaw = 0.0091;
m.DH = [
% type alpha a d theta
% ==== ===== = = =====
1 pi/2 0 1.2 pi/2 ;
1 -pi/2 0 0 -pi/2 ;
2 pi/2 0 -l_RCC 0 ;
1 0 0 l_tool 0 ;
1 -pi/2 0 0 -pi/2 ;
1 -pi/2 l_pitch2yaw 0 -pi/2 ;
];
end
0 commentaires
Réponse acceptée
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Structures dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!