How to access values in struct from another script?
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!