how to get output for n values in for loop

clc;
learningrate=0.11;
e=0;
t1=ga.time;
t=nonzeros(t1);
x=ga.signals.values;
disp(t);
w=abs(x);
p=nonzeros(w);
disp(p);
y=ga1.signals.values;
d=abs(y);
h=nonzeros(d);
disp(h);
for t=1:10
if p(t)==h(t)
h(t+1)=p(t)-(learningrate*e(t));
else
k(t)=p(t)-h(t);
%disp(k);
end
e(t)=min(k(t));
%disp(e(t))
h(t+1)=p(t)-(learningrate*e(t));
Ga1=h(t+1);
%disp(Ga1)
if Ga1==h(t)
%disp(Ga1)
else
break
end
end
disp(Ga1)
fprintf("Euclidean distance %f k(%d)\n",k(t),t);
fprintf("Minimum Euclidean distance %f e(%d)\n",e(t),t);
fprintf("Used for extraction of current values %f\n",Ga1);

3 Comments

What exactly is the question here?! This is just a section of code but there is no description of what you actually want.
In this I used the workspace data i.e. from the simulation output. I extracted time and two other values. I need p and h values corresponding to that time only. after execution I got the result for first value only
@Jyothi Polathala: I've formatted your code to improve the readability. You can do this by your own in future questions.
You still did not ask a question. It is hard to recognize the correltation between your code and teh explanations. Please mention exactly, what you want to achieve.

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Asked:

on 27 Nov 2019

Commented:

Jan
on 28 Nov 2019

Community Treasure Hunt

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

Start Hunting!