Please how do I get rid of local variables may have been changed to match the globals error?

8 visualizzazioni (ultimi 30 giorni)
I this error: Warning: The value of local variables may have been changed to match the globals. Future versions of MATLAB will require that you declare a variable to be global before you use that variable.
Also, I tried to loop over a solver because my function has a varying parameter xi. Please how I do plot a graph for the different parameters on the same figure? For instance, I wanna plot xi = -0.06 and xi=0.001 on the same figure. I have attched my code.

Risposta accettata

Torsten
Torsten il 15 Set 2022
Can you take it from here for your case ?
f = @(x,a) x.^2 + a.^2;
x = -2:0.01:2;
a = 0:0.1:1;
array = zeros(numel(a),numel(x));
hold on
for i = 1:numel(a)
array(i,:) = f(x,a(i));
plot(x,array(i,:))
end
hold off
  5 Commenti
Walter Roberson
Walter Roberson il 15 Set 2022
You do not fix it. You are treating v as if it is a function rather than an array.
Certainly you cannot fix it when there are no comments indicating what you hope to have happen there.
Note also that your right hand side does not involve i so you are calculating the same thing each iteration until you get to the point where v(i,:) and v(z,:) overlap (and which point you change what v(z,:) refers to and so you start storing different values than the iterations where i < min(z) )

Accedi per commentare.

Più risposte (0)

Prodotti


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by