I want to generate matrix [a] and I want to the value [a] in while loop.
A=randi(2,2);
b=A*transpose(A);
c=chol(b,'lower');
p=normrnd(0,1,[1,10]);
q=p(p>0); z=q(1:2);
E1=c*transpose(z);
E=transpose (E1);
K=[67.3061 -8.1429;-8.1429 59.1633]
b=[0;4];
for i=1:length(E)
a(:,:,i)=E(i)*K
x(:,1)=[0;0];
n=20;
r(:,1)=b-a(:,:,i)*x
d(:,2)=r(:,1)
k=1;
while (k<n)
p=transpose(d(:,k+1))*a(:,:,i)*d(:,k+1)
q=(transpose(r(:,k))*r(:,k));
s(k+1)=q/p
x(:,k+1)=x(:,k)+s(k+1).*d(:,k+1)
u=a(:,:,i)*d(:,k+1)
v=s(k+1).*u
r(:,k+1)=r(:,k)-v
if r(:,k+1)<=0.001
break;
end
w=transpose(r(:,k+1))*r(:,k+1);
w1=transpose(r(:,k))*r(:,k);
c(:,k+1)=w/w1;
l=d(:,k+1)
g=(w/w1)*l
d(:,k+2)=r(:,k+1)+g
k=k+1;
end
end

1 Kommentar

Dyuman Joshi
Dyuman Joshi am 21 Mai 2021
What exactly is the problem that you are facing?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange

Gefragt:

am 3 Apr. 2021

Kommentiert:

am 21 Mai 2021

Community Treasure Hunt

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

Start Hunting!

Translated by