Find with condition in loop can't create cell array
2 次查看(过去 30 天)
显示 更早的评论
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
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/152313/image.png)
0 个评论
采纳的回答
Star Strider
2015-7-19
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 个评论
Star Strider
2015-7-19
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!