How to update automatically the size of the output array in workspace after each code run?

조회 수: 1 (최근 30일)
When i run the code for the first time with the specified condition i get the solution (desiredLLP and desiredPV) which are 1x144 arrays (144 solutions).
If I change the conition in the highlithed if loop and make the interval smaller, I got for example 20 solutions but the problem is that the desiredLLP and desiredPV in workspace don't change their size to 1x20; they keep the size 1x144, so i get the first 20 solutions corrent, and the remaining elements of the array are values from the previous solution unless I delete the arrays manually from workspace before running the code.
This is the first problem. The second one, if i make the condition " if LLP(m)==0.5 "or any other value which is whithin the limits, I get the error "Undefined function or variable 'desiredLLP' " It worls only with the condition >=, <=, < or >

채택된 답변

Walter Roberson
Walter Roberson 2022년 1월 7일
desiredLLP = []; desiredPV = [];
before the for m loop.
  댓글 수: 4
ilyes louahem m'sabah
ilyes louahem m'sabah 2022년 1월 8일
This code without loop worked perfectly. Would you please explain it?
Thank you very much for your support.

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

추가 답변 (0개)

카테고리

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