![0000 Screenshot.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/257602/0000%20Screenshot.png)
how to do simple linear regression in gui?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
clear;clc;
x=[1 3 5 7 10 12 13 16 18 20];
y=[3 2 6 5 8 7 10 8 12 10];
square=x*x’;
d=x*y’;
sx=sum(x);
sy=sum(y);
N=10;
a=(N*d-sx*sy)/(N*square-sx^2);
b=(square*sy-sx*d)/(N*square-sx^2);
a
b
xx=0:25;
yy=a*xx+b;
plot(x,y,’o’,xx,yy)
axis([0 25 0 15])
title(‘data pengamatan’)
xlabel(‘x’)
ylabel(‘y’)
variabel square merupakan penampung dari hasil dari , d adalah , sx adalah jumlah dari x, dan sy adalah jumlah y. Hasil yang ditampilkan MATLAB seperti berikut ini:
a =
0.4446
b =
2.4318
1 Commento
Image Analyst
il 30 Dic 2019
Anything wrong with it? Your plot looks fine:
![0000 Screenshot.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/257602/0000%20Screenshot.png)
What do you mean by "in gui"? Your data and fit are showing up in a figure window. What else do you want? Please give explanation or sample screenshot.
Risposte (1)
khan
il 30 Dic 2019
Perhaps what you want to know is cftool; that You can run from command window (>> cftool %enter) and the input x, and y data. You can also pick the type of fitting.
Hope this help
0 Commenti
Vedere anche
Categorie
Scopri di più su Linear and Nonlinear Regression in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!