Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

iteration on embedded matlab function

1 Ansicht (letzte 30 Tage)
yana osman
yana osman am 15 Jul. 2012
hi all, i'm trying to do iteration in embedded matlab function. The coding as below:
function [P5,Q5,B5] = stats(Jacket5,E5,Mw5,Y5)
%#eml
%1st iteration
%---------------------------------------
t1 = NaN(10,1);
u1 = NaN(10,1);
w1 = NaN(3,1);
q1 = NaN(2,1);
p1 = NaN(3,1);
b2_1 = NaN(1,1);
nfactor = 1;
for l=1:nfactor
nn = 10;
t1=Jacket5;
t0=rand(nn,1);
u1=(Mw5);
k=1;
kmax=100;
while (k<kmax)
k=k+1;
t0 = t1;
w1=E5'*u1/(u1'*u1);
w1=w1/norm(w1);
t1=E5*w1;
q1=Y5'*t1/(t1'*t1);
q1=q1/norm(q1);
u1=Y5*q1/(q1'*q1);
end
p1=E5'*t1/(t1'*t1);
%regression
b2_1=u1'*t1/(t1'*t1);
end
%2nd iteration
%----------------------------------------
t2 = ones(10,1);
u2 = ones(10,1);
w2 = ones(3,1);
q2 = ones(2,1);
p2 = ones(3,1);
b2_2 = ones(1,1);
t2=t1;
u2=u1;
t0 = t2;
w2=E5'*u2/(u2'*u2);
w2=w2/norm(w2);
t2=E5*w2;
q2=Y5'*t2/(t2'*t2);
q2=q2/norm(q2);
u2=Y5*q2/(q2'*q2);
p2=E5'*t2/(t2'*t2);
%regression
b2_2=u2'*t2/(t2'*t2);
%3rd iteration
%--------------------------------------------------
t3 = NaN(10,1);
u3 = NaN(10,1);
w3 = NaN(3,1);
q3 = NaN(2,1);
p3 = NaN(3,1);
b2_3 = NaN(1,1);
nfactor = 1;
for l=1:nfactor
t3=t2;
u3=u2;
k=1;
kmax=100;
while (k<kmax)
k=k+1;
t0 = t3;
w3=E5'*u3/(u3'*u3);
w3=w3/norm(w3);
t3=E5*w3;
q3=Y5'*t3/(t3'*t3);
q3=q3/norm(q3);
u3=Y5*q3/(q3'*q3);
end
p3=E5'*t3/(t3'*t3);
%regression
b2_3=u3'*t3/(t3'*t3);
end
%store in matrices
T5 = [t1 t2 t3];
U5 = [u1 u2 u3];
W5 = [w1 w2 w3];
Q5 = [q1 q2 q3];
P5 = [p1 p2 p3];
B5 = [b2_1 b2_2 b2_3];
but the result of second and third iteration are same as the first iteration.Why?anyone have ideas why this happened?
  4 Kommentare
yana osman
yana osman am 16 Jul. 2012
sir image analysis.your suggestion really work.Thank you.its really work
V Vaishnavi Kumar
V Vaishnavi Kumar am 13 Jan. 2013
Sir, i need to iterate an embedded matlab fcn in Simulink model for a particular no. of times. FOR and WHILE (command and iterator) are not appropriate, as the embedded block should get input and output at each iteration.
So i did this by using a digital clock input to the embedded block. thus a simple program is iterating (Simulation time / sample time of digital clock) no. of times properly...
the same logic with a lengthier program is not working, and its iterated unusually many no of times...
how this no of iterations can be controlled any idea

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by