|
"ryan " <ryanlendslasvegas@yahoo.com> wrote in message <i08q8r$mn6$1@fred.mathworks.com>...
> Hi!
> When I run this loop I obtain 5 simultaneous 'z=' statements:
> e.g.:
>
> z=
> 1 2 3 4 5
> z=
> 2 9 8 7 6
>
> is there a way to generate one matrix 'Z' with 'n' rows and the '5' colums out of these five arrays instead?
> ex:
>
> z=
> 1 2 3 4 5
> 2 9 6 7 8
> ...
> loop portion of code:
>
> for k=1:5
>
>
> for h=1:n
> i=1:n;
> j=1:n;
>
> T=Dz(i,j)*X;
>
> S=sum(T');
>
> C(i);
>
> U=(C(i)-T(i));
> d;
> h;
> X(h)=U(h)/d(h);
>
> end
>
> Z=[k;X]'
>
> for h=n;
> k;
> h;
> X';
>
> end
> end
>
> X=X';
>
>
> Thanks in advance!
Hi ryan..
Yes you can do this .. Just add a little bit more to your for loop..
Such as the part that I have mentioned with ">>>>" You can change it to columns using transpose or leaving transpose..
for k=1:5
for h=1:n
i=1:n;
j=1:n;
T=Dz(i,j)*X;
S=sum(T');
C(i);
U=(C(i)-T(i));
d;
h;
X(h)=U(h)/d(h);
end
>>>>> Z = zeros(n,k);
>>>>> Z(:,k)=[k;X]' ;
for h=n;
k;
h;
X';
end
end
X=X';
I hope it help..
Let me know if it worked..
Regards,
Faraz
|