フィルターのクリア

How to access values in struct from another script?

12 ビュー (過去 30 日間)
Laurel Castillo
Laurel Castillo 2018 年 12 月 1 日
編集済み: Stephen23 2018 年 12 月 1 日
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

採用された回答

Stephen23
Stephen23 2018 年 12 月 1 日
編集済み: Stephen23 2018 年 12 月 1 日
Just return that structure when you call ArmModel inside CAL.m:
m = ArmModel();
DH = m.DH;

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by