0
votes

I have the following code in Mathematica and need to convert it into Matlab but cant for the life of me understand how to do it, though i think i need to use the fzero; command. Please could someone help me or give me a hint?

function f has already been defined but i need to find its roots for where variable a is from 0-0.6 etc.

list1 = For[a=-0.01, a<0.6, a+=0.01; sol=Findroot[f,{u, 1.00,1.10}];
v1[i] = sol[[1,2]]; i++]
1

1 Answers

0
votes

Reading Matlab's documentation, I guess what you want is similar to:

To find a zero of the function f(x) = x3 – 2x – 5, write an anonymous function f:

f = @(x)x.^3-2*x-5;

So:

i = 1;
for a = -0.01:0.01:0.6
    f = @(x)x.^3-2*x-a;
    sol = fzero(f,1.0);
    v[i] = sol(something); %depending on which solution you are interested in
    i = i+1;
end