How to add a trendline with ployfit

1 visualización (últimos 30 días)
Sean St Cyr
Sean St Cyr el 13 de Nov. de 2020
Respondida: SaiDileep Kola el 16 de Nov. de 2020
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

Respuestas (1)

SaiDileep Kola
SaiDileep Kola el 16 de Nov. de 2020
Hi Sean,
you can have a look over it.

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by