I have the following Matlab program;
k=1:1:10;
a=[3,5,2];
for j=1:length(k)
for h =1:1:length(a)
x=a(h);
y1(h)=x^j-2;
end
minfind(j)=min(y1);
end
plot(k, minfind)
I tried to write Mathematica code that perform the same calculation. So far I wrote the following Mathematica code
a = ( { {3, 5, 2} } );
For[j = 1, j <= 10, j = j + 1,
For[h = 1, h <= 3, h = h + 1,
x = a [[1, h]];
y22 = x^j-2;
y1 = Append[y1, y22];
];
ymin1 = Min[y1];
minfind = Append[minfind, ymin1];
]
But the above code doesn't work.
Can anyone help in pointing what is wrong with the above code and what is the correct code?