Find with condition in loop can't create cell array

1 view (last 30 days)
Hello, i have to crate a new vector that will have the different number of peaks in each row for each pulse. So i have this graph where red squares are the minimal and the blue are the peaks for each pulse as you can see. These vectors are pks=[4432 4434 4452 4413 4402 4406 4395 4397 4347 4408 2486 1761 1771 1788 3953], the peaks , lo=[175 203 262 454 553 773 852 1054 1167 1369 1560 1738 1800 1860 2023], the locations of the peaks, also vect=[67 353 646 951 1265 1540], the locations of the minima. Hence i will need to use the find funtion and them store my results to cell, as the number of peaks may differ as you can see from the photo. I did all the above but i get error saying that "Cell contents assignment to a non-cell array object" , here is my code maybe i am missing something but i can't really understand what i am doing wrong , any help really appreciated ,thanks in advance.
for k=1:size(vect,2)
az{k}=find( lo>vect(k) & lo<vect(k+1) );
end

Accepted Answer

Star Strider
Star Strider on 19 Jul 2015
You must have assigned ‘az’ to something else (other than a cell array) earlier in your code. It is probably easiest to simply rename ‘az’ in the loop, for instance:
for k=1:size(vect,2)
azc{k}=find( lo>vect(k) & lo<vect(k+1) );
end
  3 Comments
Star Strider
Star Strider on 19 Jul 2015
My pleasure.
You can run this from the Command Line or in your script to display all the current variables in your Workspace and their classes:
list_variables = whos;
variable_names_and_classes = {list_variables.name; list_variables.class}'
Be sure to choose some names you wouldn’t otherwise use in your code to assign the result of the whos call and the cell array, so you don’t inadvertently overwrite them. Note that you can also ask for other information about them. Remove the semicolon (;) after the whos call to see all the options.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!