How to calculate repeated calculation using LOOP?
Ältere Kommentare anzeigen
I have 2 tables as below:
NetCh - has 12 column (var1 var2 ... var12) and 9 rows
yPeriod1 - has 1 column and 9 rows
I would like to calculation within each column in NetCh for 12 times and write 12 results (Der1 Der2 .. Der12) in a new table.
Now I have to do by mannually all of them.
Can you please tell me make it small code using LOOP.
NetCh1 = table(NetCh.Var1)
NetCh1.Hangal = (NetCh1{:,1}).*(yPeriod1{:,1})
NetCh1.Haliun = (yPeriod1{:,1}).^2
Tr1 = sum(yPeriod1{:,1})
Br1 = sum(NetCh1{:,1},'omitnan')
Hr1 = sum(NetCh1.Hangal,'omitnan')
Qr1 = sum(NetCh1.Haliun)
Der1 = Br1*Qr1-Tr1*Hr1
NetCh2 = table(NetCh.Var2)
NetCh2.Hangal = (NetCh2{:,1}).*(yPeriod1{:,1})
NetCh2.Haliun = (yPeriod1{:,1}).^2
Tr2 = sum(yPeriod1{:,1})
Br2 = sum(NetCh2{:,1},'omitnan')
Hr2 = sum(NetCh2.Hangal,'omitnan')
Qr2 = sum(NetCh2.Haliun)
Der2 = Br2*Qr2-Tr2*Hr2
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Logical finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
