MATLAB Answers

Help with Matlab code

3 views (last 30 days)
Hi i need help creatimg a code for tbe question attached. I've plotted the point but im not getting the equation that I need. Is there anyone out there who can help with a code?


Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 3 Dec 2019
Looks like polyfit() should do it
temperature = [.........
enthalpy = [...........
coefficients = polyfit(temperature, enthalpy, 1);
% Slope = coefficients(1), intercept = coefficients(2)
See if you can finish it.


Devanee Moreno
Devanee Moreno on 3 Dec 2019
Thank you so much for the answer. What I also was wondering was how do I mange to print just the slope on the command window so I can insert it into an equation and muliply it out?
Image Analyst
Image Analyst on 3 Dec 2019
slope = coefficients(1)
intercept = coefficients(2)
y = slope * x + intercept
Don't use semicolons so that they print to the command window.
y is the fitted enthalpy and x is what temperature values you want it over, like perhaps the original temperature values, or even more temperatures if you want
numPoints = 500; % Whatever you want.
x = linspace(min(temperature), max(temperature), numPoints);

Sign in to comment.

More Answers (0)

Sign in to answer this question.