MATLAB Answers

Graph plot with given range

조회 수: 10(최근 30일)
Abdullahi Abubakar
Abdullahi Abubakar 6 Apr 2021
댓글: Abdullahi Abubakar 7 Apr 2021 9:00
for mcap=0:0.1:100
mbat = (35000-10000*mcap)/3000;
end
for mbat=0:0.1:100
mcap = (35000-3000*mbat)/10000
end
plot(mbat,mcap,'ro')
Please can someone make a correction for me? i want to plot this graph so that all the intersection points should appear, but I am having only the last series intersection point appearing on the graph.
Thanks you

채택된 답변

dpb
dpb 6 Apr 2021
You didn't allocate for each element of the output arrays but computed each point one-at-a-time by using an unneeded for...end loop. Use MATLAB array syntax instead--
v=0:0.1:100;
mbat = (35000-10000*v)/3000;
mcap = (35000-3000*v)/10000;
plot(mbat,mcap,'ro')
NB: I also took out the reuse of same variable and redefinition of mcap as both input and output in lieu of a single variable, v, for the independent variable.
  댓글 수: 1
Abdullahi Abubakar
Abdullahi Abubakar 7 Apr 2021 9:00
Thank you very much

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

추가 답변(0개)

태그

Community Treasure Hunt

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

Start Hunting!

Translated by