필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Find value in a cell array

조회 수: 2 (최근 30일)
Morgan Roberts
Morgan Roberts 2018년 1월 10일
마감: MATLAB Answer Bot 2021년 8월 20일
Hi,
I am trying to find out if a certain bin in a table contains a certain value based on another vector.
b= 0;
b2 = 0;
r = branches(:,1);
r2 = r;
k = 0
for i = 1:length(r)
b = size(r{i},1) + b;
for j = 1:no_syn
b2 = find(b > Postdiam(j));
r2{i} = r(b2);
if b2 == 1
r2{i} = {'SYNAPSE'};
else
r2{i} = {'NO SYNAPSE'};
end
branches(:,4) = r2;
k = j(b2)
end
end
From this, whenever the synapse value is found, in this case it's 245 and 246, I want it to pop up with SYNAPSE.
19x4 double 92.8117570643396 'BRANCH' 'NO SYNAPSE'
32x4 double 115.752266229064 'BRANCH' 'NO SYNAPSE'
4x4 double 27.1259128701332 'BRANCH' 'NO SYNAPSE'
132x4 double 359.891498931659 'BRANCH' 'NO SYNAPSE'
6x4 double 34.5092311768868 'BRANCH' 'NO SYNAPSE'
31x4 double 83.1975489342949 'BRANCH' 'SYNAPSE'
47x4 double 136.221229624204 'BRANCH' 'SYNAPSE'
37x4 double 63.5355126390744 'BRANCH' 'SYNAPSE'
Which I have managed to do, but I want the loop to stop as the bins above the target bin now say SYNAPSE. Does anyone have any ideas?
Cheers
  댓글 수: 2
Ben Drebing
Ben Drebing 2018년 1월 12일
Can you describe what you would like to accomplish in some more detail? You said you would like the loop to stop. Once you find the target bin, you could use "return" or "break" to end the loop.
Guillaume
Guillaume 2018년 1월 12일
I'm fairly certain that a loop is not needed but to know for sure a clearer explanation of the algorithm and some example data would be useful.
I would recommend using meaningful variable names and commenting your code. You can be certain you'll have a hard time understanding the code you've written if you come back to it in a year's time.
Does your code actually involve tables?

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by