필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
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.

채택된 답변

Torsten
Torsten 2022년 9월 15일
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
Walter Roberson
Walter Roberson 2022년 9월 15일
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) )

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by