Hi all,
I have a newbie question, how to use structural variable properly? A minimum example:
clear; clc;no.inpt = 5;inpt.a1 = rand(no.inpt);inpt.a2 = rand(no.inpt);inpt.a3 = rand(no.inpt);[otpt] = teststruct(inpt);[otpt] = teststruct1(otpt);
where the two functions are:
function [otpt] = teststruct(inpt)otpt.x = inpt.a1 + 3 * inpt.a2 - inpt.a3;otpt.y = 2 * inpt.a3;
and
function [otpt] = teststruct1(inpt)otpt.z = inpt.x * 2 + inpt.y * 3;
After this, variable otpt only contains one subfield z which I understand that teststruct1 regenerate otpt. However, what I want is to let otpt keep three subfields x, y and z without renaming otpt after function teststruct. How could I achieve it?
Many thanks!
Best Answer