How to add a trendline with ployfit
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (1)
SaiDileep Kola
el 16 de Nov. de 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 comentarios
Ver también
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!