Azzera filtri
Azzera filtri

How to save values of loops ?

2 visualizzazioni (ultimi 30 giorni)
Fox
Fox il 4 Gen 2016
Commentato: Fox il 4 Gen 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.

Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 4 Gen 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 Commento
Fox
Fox il 4 Gen 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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Sparse Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by