필터 지우기
필터 지우기

What is wrong in this code??

조회 수: 1 (최근 30일)
theintern
theintern 2017년 10월 17일
댓글: theintern 2017년 10월 18일
Could you please help me to solve the problem? Loop cannot stop.
Attached you can find the file. The function is digdata and the other is code. Thank you.

채택된 답변

Jan
Jan 2017년 10월 17일
In this loop:
while abs(res1)>0.01
As = vq.*(Us(j).^2)./(16.*(pi.^2).*msksi.*fs1(j));
res1 = As1(i)-As;
end
you calculate the same value in each iteration. As will never change its value. Therefore this must be an infinite loop.
Due to the missing comments, the purpose of this loop cannot be guessed. Therefore a reliable suggestion of improvement cannot be given.
  댓글 수: 1
theintern
theintern 2017년 10월 17일
Sorry, I am kind of new in Matlab. I am trying to apply attached step. Equation is the As formula that I wrote.

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

추가 답변 (1개)

theintern
theintern 2017년 10월 18일
I changed this code with attached code, but I think the problem is in digdata function. I would like to find vq values which correspond (As(i), Vs). There is a dimensional problem that I couldn't solve.
  댓글 수: 2
Jan
Jan 2017년 10월 18일
편집: Jan 2017년 10월 18일
Please post details belonging to the question by editing the question, not as answers. Thanks.
"There is a dimensional problem that I couldn't solve." Then please post any details. Do you get an error message? Then post it completely.
The clear all in your code destroys the current work, if somebody tries to your code to help you. It is much smarter to store the code in a function instead of clearing everything brutally.
Your code will be much easier to read, if you select it an press Ctrl-I in the editor.
theintern
theintern 2017년 10월 18일
Thank you, I will be more careful then. I solved the problem.

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

카테고리

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