derive slope from plotInteraction
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Arianna Menardi
am 4 Mär. 2024
Beantwortet: Mathieu NOE
am 4 Mär. 2024
Dear experts, I would like to extract the slopes of the lines you see when you use the plotinteraction command on multiple linear regression analysis. For example, I'm attaching the plotInteraction from the Mathworks tutorial on linear regression (https://it.mathworks.com/help/stats/linearmodel.plotinteraction.html). How can I derive the slope of the purple, yellow and red lines of the attached figure?![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1634446/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1634446/image.png)
0 Kommentare
Akzeptierte Antwort
Mathieu NOE
am 4 Mär. 2024
hello
FYI, you can access any figure underlying data (and of course compute the slope)
openfig('myfig.fig');
set(gcf, 'Visible','off')
Ax = gca; % Another Option
Lines = findobj(Ax, 'Type','line'); % Return Handles To All 'Line' Objects
x = Lines.XData(:); % Independent Variable (Force Column Vector With '(:)')
y = Lines.YData(:); % Dependent Variable (Force Column Vector With '(:)')
Figure_Table = table(x,y, 'VariableNames',{'X values','Y values'})
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Linear Regression finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!