How to add a trendline with ployfit
3 views (last 30 days)
Show older comments
I have the following code, and I am trying to put a trendline to the graph that it outputs, How would i do that with polyfit to this code?
if strcmp(choice,'Detail')
[q,tf] = listdlg("PromptString",'Choose a material', "ListString", Information.Material); %prompts the list dialoug box
if tf == 1
x0 = (q*2)-1;
y0 = q*2;
for D = 1:1:length(q)
plot(Data(x0(D),2:end),Data(y0(D),2:end),Information.Format{q(D)}) %plot data
grid on
hold on
lnd{L} = Information.Material{q(D)};
L = L+1;
end
xlim([0 10]) %Sets x axis from 0-10
ylim([0 100]) %Sets y axis from 0-100
xlabel('Time (t) [min]'); %X-axis label
ylabel('Temperature difference (T) [°C]'); %Y-axis label
title('Detailed Plot of Selected Materials'); %Title of graph
end
if tf == 0
error('PLEASE MAKE A SELECTION') % if there is no choice then produce the error
end
end
0 Comments
Answers (1)
SaiDileep Kola
on 16 Nov 2020
Hi Sean,
Similar query is answered at https://www.mathworks.com/matlabcentral/answers/57253-adding-trendline-to-a-plot
you can have a look over it.
0 Comments
See Also
Categories
Find more on 2-D and 3-D Plots 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!