How to get Matlab to calculate answers from linspace

4 views (last 30 days)
Hi, I want to calculate the temp change from years 1 to 5; however I keep getting nothing when I run the code. Would appreciate any help.
T0 = 473.15; %initial temp
r = 10; %cooling in C per year
t = linspace(0,5,1); %trying to find temp change from years 1-5 for each year
T = T0-r.*t; %equation

Accepted Answer

Walter Roberson
Walter Roberson on 1 Apr 2018
You have
linspace(0,5,1)
linspace(A, B, C) requests that you take a total of C point starting from A and ending at B (inclusive in both cases.) So you are asking for there to be only 1 point.
If you want integer year numbers use 1:5

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!