i need to vector that saves mse final value and than plot it. how do i do that? how to create vector that saves all the answers?
if true
% code
end
function [finalW, MSE, Numiterations] = gradientDescentLinearNeuron(x, t, lr, ErrorGoal, MaxIterations)
FinalW=(2*rand(1,(size(x,1)))-1)/10;
MSE=1/(size(x,2)*((sum(t-FinalW*x).^2)));
%ErrorGoal=0.15;
%lr=0.1;
step=1;
while ((MSE>ErrorGoal)&&(step<=MaxIterations))
y=FinalW*x;
dMSEdw=-1/((size(x,2)*((t-y))*x'));
FinalW=FinalW-lr*dMSEdw;
MSE=1/(size(x,2)*((sum(t-FinalW*x).^2)));
step=step+1;
end
vectorMSE=
plot(vectorMSE,step);
end

답변 (1개)

madhan ravi
madhan ravi 2018년 11월 8일
편집: madhan ravi 2018년 11월 8일

0 개 추천

a=1:10; %an example
i = 1;
while i<=numel(a)
b(i) = a(i).^2; %(i) in order to avoid overwriting
i=i+1;
end
b

댓글 수: 3

madhan ravi
madhan ravi 2018년 11월 8일
b is now a vector likewise adapt it to your case
will it work inside a while loop?
madhan ravi
madhan ravi 2018년 11월 8일
see edited answer

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품

릴리스

R2018b

질문:

2018년 11월 8일

댓글:

2018년 11월 8일

Community Treasure Hunt

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

Start Hunting!

Translated by