Doubt involving a for loop within another

조회 수: 1 (최근 30일)
Ana Carolina da Silva Pacheco
Ana Carolina da Silva Pacheco 2021년 5월 16일
I have the code below that is returning the results shown:
My problem is that I want the variable "jvals" to be a matrix just like "vetor_momentoj", so that I can store the values returned from the linspace of each interaction i=1:it. Can anybody help me, please?
P.S. this is just a test code, and the value 0.03 used to define jvals is hypotetical. In the real code this value depends on the index i.

채택된 답변

David Fletcher
David Fletcher 2021년 5월 16일
Try changing the line to:
jvals(i,:)=linspace(0,0.03,n)
You may also need to change the line to
curvatura=jvals(i,j)
if curvatura is intended to be a scaler in that loop (though I don't see where it is used, so I assume you haven't added it to the code)
  댓글 수: 1
Ana Carolina da Silva Pacheco
Ana Carolina da Silva Pacheco 2021년 5월 16일
Thank you, that worked! Yes, curvatura is used in a fzero function that I didn't add to the test code.

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

추가 답변 (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