I need to create the following plots in the same figure window but the green graph is remaining constant when it should be a negative graph

조회 수: 1 (최근 30일)
Whenever I run each graph separatly it displays correctly but when I try to have them all on the same plot using the hold on and hold off functions the green graph remains constant when it should be a negative sloping curve. Any suggestions?
%Increase=input('Enter percent of increase :')
%Decrease=input('Enter percent of decrease :')
%Remain_Constant=input('Enter 0 to remain constant :')
Increase=0.15;
Decrease=-0.1;
Remain_Constant=0;
years=[11:1:50];
%Current_value=Total_mismanaged_kg_year;
Current_value=3273763.092;
annual_rate_increase=Increase;
annual_rate_decrease=Decrease;
annual_rate_remain=Remain_Constant;
Future_growth_increase=(1+ annual_rate_increase).^years;
Future_growth_decrease=(1+ annual_rate_decrease).^years;
Future_growth_constant=(1+ annual_rate_remain).^years;
Future_value_increase=Future_growth_increase*Current_value;
Future_value_decrease=Future_growth_decrease*Current_value;
Future_value_remain=Future_growth_constant*Current_value;
%figure;plot(years,Future_value_increase,'b')
%hold on
%plot(years,Future_value_decrease,'g')
%plot(years,Future_value_remain,'r')
%hold off
figure;semilogy(years,Future_value_increase,'b')
hold on
semilogy(years,Future_value_decrease,'g')
semilogy(years,Future_value_remain,'r')
hold off
  댓글 수: 6
Torsten
Torsten 2022년 7월 10일
편집: Torsten 2022년 7월 10일
My guess is that the values for the green graph are that low that they cannot be distinguished from the x-axis.
Try a logarithmic plot for the three curves (see above).
Karan Singh
Karan Singh 2023년 9월 28일
Hi Allison, from what I see the green graph is a negative slope and while running individually as well as running with hold off and on , and does not make a difference in my machine. Can you explain cause I am not able to see any problem.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by