MATLAB: Storing data in an array from a loop

for loop

I have:
A1=(1:1:10)*1.22';
A2=(1:1:10)*2.55';
for cc=(A1+A2)/2;
G1=[1 2];
G2=[2.6 1.1];
X=(fsolve(@(x)sum(G1.*sin(G2.*x)),cc))'
end
and I want the results for X to be stored in an array

Best Answer

A1=(1:1:10)*1.22';
A2=(1:1:10)*2.55';
i=1;
for cc=(A1+A2)/2;
G1=[1 2];
G2=[2.6 1.1];
X(i)=(fsolve(@(x)sum(G1.*sin(G2.*x)),cc))'
i = i+1;
end
I think this will work!
Related Question