From: Andrés Suárez on
Hi,

Playing with fsolve, I reached to a point where two equivalent
portions of code, at first glance, produce different results. In
"case
A" the program does correctly the optimization, but in "case B" it
can't do it. Why?

Link to source code: http://friendpaste.com/688QhEDslwwvG9g7UJH6N1

Thanks and regards,
Andrés
From: Andrés Suárez on
On 12 ago, 18:14, Andrés Suárez <ans...(a)gmail.com> wrote:
> Hi,
>
> Playing with fsolve, I reached to a point where two equivalent
> portions of code, at first glance, produce different results. In
> "case
> A" the program does correctly the optimization, but in "case B" it
> can't do it. Why?
>
> Link to source code:http://friendpaste.com/688QhEDslwwvG9g7UJH6N1
>
> Thanks and regards,
> Andrés

I don't understand why, but the solution to case B is:

indep_var = {'v1'; 'v2'; 'v3'};
for i = 1:length(independent_values)
str = [indep_var{i} ' = independent_values(i);'];
commands{i} = str;
end
for i = 1:length(commands)
eval(commands{i});
end

Regards,
Andrés
From: Walter Roberson on
Andrés Suárez wrote:

> eval(commands{i});

Using eval() is like throwing around water-balloons full of sulphuric
acid -- no matter how carefully you aim and catch the balloons, sooner
or later the acid is going to rot out the balloon and leave you with a
dangerous mess to clean up.
 | 
Pages: 1
Prev: regionprops
Next: variables in recursion