Borrar filtros
Borrar filtros

Scatter plot and linear regression

5 visualizaciones (últimos 30 días)
Andressa
Andressa el 27 de Abr. de 2024
Respondida: Star Strider el 29 de Abr. de 2024
Hi! I have a data set that contains several columns the first is a categorical one with name of different species and the ogther ones are numerical values with chemical measurements for each species. I need to make a xy plot, considering the x will be the values measured for one species and y will be the values from another species. Then I need to do a linear regression to find a slope, below is a example of my data. Can someone help me?

Respuestas (1)

Star Strider
Star Strider el 29 de Abr. de 2024
It would help to have your data and a description of what you want to plot and regress against what else.
Then, use the lsline function —
Data = sort(rand(25, 4))+rand(1,4);
figure
hs = scatter(Data(:,1), Data(:,2:end), 'filled');
grid
hlsl = lsline;
species = ["A" "B" "C"];
for k = 1:numel(hlsl)
B(:,k) = [hlsl(k).XData; 1 1].' \ hlsl(k).YData.';
hlsl(k).Color = hs(numel(hlsl)-k+1).CData;
hlsl(k).DisplayName = "Species "+species(k);
end
legend(hlsl, 'Location','best')
This identifies each group and regression by colour. The slopes and intercepts of each regression are in the ‘B’ matrix.
.

Categorías

Más información sobre Descriptive Statistics en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by