How to save values of loops ?

2 vues (au cours des 30 derniers jours)
Fox
Fox le 4 Jan 2016
Commenté : Fox le 4 Jan 2016
I made the following for loop and now want to save the different values I get on my command window in one vector: My Problem is that the following code doesn't work.
be=zeros(16,1);
for s=1:2:16
bety1=((z3(0+s:1+s,1:20)*z3(0+s:1+s,1:20)')^-1)*(z3(0+s:1+s,1:20)*y3(1:20));
be(s)=bety1
end
Can somebody help me ? Perhaps you need the info that at every bety1 I get a vector with 2 rows so in the end I should have a vektor with 16 rows.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 4 Jan 2016
be=zeros(16,1);
for s=1:2:16
bety1=((z3(0+s:1+s,1:20)*z3(0+s:1+s,1:20)')^-1)*(z3(0+s:1+s,1:20)*y3(1:20));
be(s:s+1)=bety1
end
  1 commentaire
Fox
Fox le 4 Jan 2016
Thanks. Could you perhaps help me with the following similar problem ? Here I want to do the same but with the double for loop it doesn't work. End should be a matrix with 16 rows and 41 colums.
bee=zeros(16,41)
for i=1:41
for k=1:2:16
bety2=((z3(0+k:1+k,1+i:20+i)*z3(0+k:1+k,1+i:20+i)')^-1)*(z3(0+k:1+k,1+i:20+i)*...
y3(1+i:20+i));
bee(k:k+1,i:i+1)=bety2
end
end

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Sparse Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by