How to Create Structure within a Function

조회 수: 2 (최근 30일)
jrz
jrz 2022년 10월 23일
댓글: jrz 2022년 10월 23일
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일
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개)

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by