making a non linear graf

조회 수: 2 (최근 30일)
slowlearner
slowlearner 2020년 5월 2일
댓글: slowlearner 2020년 5월 2일
hey I have no idea on how to make a graf of a diminishing value for an equation i made.
It's just to represent the degradation of a battery that has a loss of 2.3% per year like this:
100(1-0.023) I've tried the for funktion but Don't think i enter correct values
would appriciate the help
  댓글 수: 3
Ameer Hamza
Ameer Hamza 2020년 5월 2일
What is the equation? '100(1-0.023)' is just a constant value.
slowlearner
slowlearner 2020년 5월 2일
Hmm.. maby f(x)=n(1-×) P(×)=f(×)(1-×) and so on x has a known value now tho

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

채택된 답변

Image Analyst
Image Analyst 2020년 5월 2일
Try this:
initialAmount = 100;
amountLeft = initialAmount;
maxNumberOfYears = 50;
for k = 2 : maxNumberOfYears
amountLeft(k) = amountLeft(k - 1) * (1-0.023);
fprintf('After %d years, the amount left = %.2f\n', amountLeft(k));
end
plot(amountLeft, 'b.-', 'LineWidth', 2, 'MarkerSize', 20);
grid on;
xlabel('Time (Beginning of Year)', 'FontSize', 20);
ylabel('Amount Left', 'FontSize', 20);
g = gcf;
g.WindowState = 'maximized';
  댓글 수: 1
slowlearner
slowlearner 2020년 5월 2일
Nice thanks! I really need to work on my loop functions.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by