フィルターのクリア

How to transfer matrix values loaded in one subfunction to the main function?

1 回表示 (過去 30 日間)
ruik zhang
ruik zhang 2018 年 7 月 25 日
編集済み: Giridharan Kumaravelu 2018 年 7 月 25 日
Hi, I want the matrix values loaded in subfuction can be used in the main function which calls the subfunction. For example: function calulation (main function) [a b]= calculation2 (fubfunction) when the subfunction calculation2 is runing, two matrix is loaded: A=(''); B=(''). My question is now: How can I use the A and B value inside the calculation and then I don't need to reload the two matrix again.
thanks

回答 (1 件)

Giridharan Kumaravelu
Giridharan Kumaravelu 2018 年 7 月 25 日
編集済み: Giridharan Kumaravelu 2018 年 7 月 25 日
You could use them as global variables as shown below
function calculation
global A
global B
[a,b] = calculation2();
A
B
end
function [a,b] = calculation2()
a = 0;
b = 0;
global A
global B
A = eye(3);
B = eye(4);
end

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by