Make calculations based on previous results

조회 수: 1 (최근 30일)
Nikolas Spiliopoulos
Nikolas Spiliopoulos 2017년 2월 21일
댓글: Nikolas Spiliopoulos 2017년 2월 21일
Hi all,
I have an array of 48x365, I need to make some calculations with the first column and use some of the results to do similar calculations with the second column. then the results of the second to do calculations with the 3rd and so on..
do you have any ideas how to do it without using simulink?
thanksa lot

답변 (1개)

John D'Errico
John D'Errico 2017년 2월 21일
A loop seems trivial and obvious, even though you give no indication of what computations you need to do. If you don't have any idea how to write a loop, then you need to spend some time reading the getting started tutorials. At the very least, read the help about for.
doc for
You DO want to preallocate the array to be 48x365 in advance, else your next anguished question will be "Why is my code so slow?"
  댓글 수: 3
John D'Errico
John D'Errico 2017년 2월 21일
편집: John D'Errico 2017년 2월 21일
You don't say what is "different". Obviously, you know what the computation is, so clearly you can write the code, or at least it can be written. But if there is no point in giving details, then how can I answer you?
You have a computation that depends on some parameter, as well as the previous column. That it is in a loop is not relevant. You can always access the previous column, as a function of the loop index.
Nikolas Spiliopoulos
Nikolas Spiliopoulos 2017년 2월 21일
ok i will give it a try, thanks anyway!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by