How To Delete an Element In a Vector That Is Also In a Cell Array?
Show older comments
So I have a cell array and in the array I have a vector. I would like to delete a specific value from the vector and I can't figure out how to do that without deleting the entire array. Here is my code for the array:
{'sin',{'0','2pi','pi/100'},['0','1','1','0']}
As you can see, I have a vector of 4 elements in the last cell and I want the third on gone. How would I do that?
Answers (1)
Walter Roberson
on 22 Nov 2017
YourCell{end}(3) = [];
2 Comments
Notoro
on 22 Nov 2017
Walter Roberson
on 22 Nov 2017
In the case where all of those third elements have the same number of entries:
T = mat2cell(YourCell(:,3));
newCell = [YourCell(:,[1 2]), num2cell(T(:,[1:2 4:end]), 2)];
Categories
Find more on Cell Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!