Filter löschen
Filter löschen

Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

Find value in a cell array

2 Ansichten (letzte 30 Tage)
Morgan Roberts
Morgan Roberts am 10 Jan. 2018
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
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 Kommentare
Ben Drebing
Ben Drebing am 12 Jan. 2018
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 am 12 Jan. 2018
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?

Antworten (0)

Diese Frage ist geschlossen.

Community Treasure Hunt

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

Start Hunting!

Translated by