How to Create Structure within a Function

I have a function that calculates a number of values, for simplicity, lets call them x,y,z. I want to create a structure within the function that saves these values for use in other functions. How can this be done?

 採用された回答

Can Atalay
Can Atalay 2022 年 10 月 23 日

0 投票

You mean like this?
function [structure_youre_trying_to_create] = function_youre_using(input_1,input_2)
x = input_1+input_2
y = input_1*input_2
z = x*y
structure_youre_trying_to_create = struct();
structure_youre_trying_to_create.addition = x;
structure_youre_trying_to_create.multiply = y;
structure_youre_trying_to_create.combine = z;
end

1 件のコメント

jrz
jrz 2022 年 10 月 23 日
Exacty like that, thanks so much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeStructures についてさらに検索

質問済み:

jrz
2022 年 10 月 23 日

コメント済み:

jrz
2022 年 10 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by