필터 지우기
필터 지우기

My loop returns no errors however doesn't product any results

조회 수: 2 (최근 30일)
Franchesca
Franchesca 2014년 5월 14일
댓글: Star Strider 2014년 5월 14일
I have this script shown below:
%% Combine the data
SWOA = [3,100];
CWOA = [3,100];
SWA = [3,100];
CWA = [3,100];
for i = 1:length(mydata)%loop to group data together into jump types
if grouped(i,2) == 1
SWOA(i,1) = grouped(i,1:2)
else if grouped(i,2) == 2
CWOA(i,1) = grouped(i,1:2)
else if grouped(i,2) == 3
SWA(i,1) = grouped(i,1:2)
else if grouped(i,2) == 4
CWA(i,1) = grouped(i,1:2)
else if grouped(i,2)== 0
continue
end
end
end
end
end
end
However, once I've ran the script the variable are created however the loop doesn't fill them with any data but doesn't return any errors. What I am trying to do is if a cell = 1 put that cell and the same row from column 1 into the variable SWOA, if it equals 2 put that cell and the same row from column 1 into the variable CWOA and so on...
How would I do this
  댓글 수: 2
Sara
Sara 2014년 5월 14일
You'll have to attach the variable grouped for people to help. Looking at the code, I'd say the condition "else if grouped(i,2)== 0" is always true so array gets filles.
Franchesca
Franchesca 2014년 5월 14일
Sorry here is a copy of the varaible grouped:

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

채택된 답변

Star Strider
Star Strider 2014년 5월 14일
I suggest inserting this line right after your for statement:
grouped_var = grouped(i,2)
without a semicolon on the end so that it displays to the command window.
My guess is that grouped(:,2)=0.
  댓글 수: 3
Franchesca
Franchesca 2014년 5월 14일
Thank you very much!!

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

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