フィルターのクリア

Info

この質問は閉じられています。 編集または回答するには再度開いてください。

multiple line plot inside a loop

1 回表示 (過去 30 日間)
fima v
fima v 2020 年 3 月 12 日
閉鎖済み: fima v 2020 年 3 月 12 日
Hello,I have built linear regression algorithms.
but i cant see the final reult onle as shown bellow.
is there a way to plot the line each ten itterations?
Thanks.
T=readtable('data.csv');
x=table2array(T(:,1));
y=table2array(T(:,2));
m=0; %current place of the person
c=0; %
L=0.0001;
epocs =1000; %thouthand etarations
n=length(x);
for i=1:length(x)
y_pred=m*x+c;
D_m=(-2./n)*sum(x.*(y-y_pred));
D_c=(-2./n)*sum(y-y_pred);
m=m-L*D_m;
c=c-L*D_c;
end
plot(x,y,'.b');
hold;
plot(x,y_pred);
  1 件のコメント
fima v
fima v 2020 年 3 月 12 日
T=readtable('data.csv');
x=table2array(T(:,1));
y=table2array(T(:,2));
m=0; %current place of the person
c=0; %
L=0.0001;
epocs =1000; %thouthand etarations
n=length(x);
plot(x,y,'.b');
hold;
for i=1:length(x)
y_pred=m*x+c;
D_m=(-2./n)*sum(x.*(y-y_pred));
D_c=(-2./n)*sum(y-y_pred);
m=m-L*D_m;
c=c-L*D_c;
plot(x,y_pred);
end
%plot(x,y_pred);

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by