필터 지우기
필터 지우기

How to initialize an empty vector/null vector in matlab,

조회 수: 158 (최근 30일)
Sai
Sai 2015년 8월 8일
댓글: Walter Roberson 2015년 8월 8일
I would like to transfer the u_real(n) value to the u_Q1(n) array. But, when I am trying to compile it is telling me that the variable u_Q1 is undefined. How can I define that variable as empty vector.
u_real=real(u);
v_real=real(v);
temp = 0;
for n = 1:100
if and(u_real(n)>0,v_real(n)>0)
if n == temp + 1
u_real(n) == u_Q1(n);
v_real(n) == v_Q1(n);
temp = n;
else
d = n-temp;
u_real(n) == u_Q1(n-d+1);
v_real(n) == v_Q1(n-d+1);
temp = n-d+1;
end
end
end
  댓글 수: 2
James Tursa
James Tursa 2015년 8월 8일
"... transfer the u_real(n) value to the u_Q1(n) array ..."
Looks to me like you are doing the opposite. What is your actual intent?
Sai
Sai 2015년 8월 8일
Ahh..! I'm soo dumb, I just found that.. Sorry but my intention was to transfer the u_real(n) value to a vector. Can you suggest me. Thanks.

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

채택된 답변

Walter Roberson
Walter Roberson 2015년 8월 8일
  댓글 수: 1
Walter Roberson
Walter Roberson 2015년 8월 8일
u_real(n) == u_Q1(n);
means to compare u_real(n) to u_Q1(n) for equality and have a value of 0 if they are not exactly equal and 1 if they are exactly equal. Then once that logical 0 or 1 is calculated, the result is discarded because the ";" at the end of the line means not to display the value of the expression.
You probably want to use assignment = instead of comparing values ==

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by