How to add a trendline with ployfit

3 次查看(过去 30 天)
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

回答(1 个)

SaiDileep Kola
SaiDileep Kola 2020-11-16
Hi Sean,
you can have a look over it.

类别

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