MATLAB Answers

how to delete cells in a cell array, such that it has the same length as one of my other arrays

8 ビュー (過去 30 日間)
Joyce Dieleman
Joyce Dieleman 2019 年 9 月 26 日
回答済み: Ankit 2019 年 9 月 26 日
I am trying to delete cells in a cell array, such that is has the same length as one of my other arrys
I have a cell array of 23x1 cell which cotains numbers (all different ones) --> call it X
X =
2223
2338
3449
3599 and so on
I have another cell aray of 24x 1 cell which contains numbers as well (the same number in every cell) --> call it Y
Y =
2222
2222
2222
2222
2222 and so on
I want that my Y variable gets the same length as my X variable, by removing one of the cells in this cell array.
How can I program this? As they will differ in length and I need to do this multiple times, I probably need something with length or numel.
I tried several things, but none is working yet.
Hope you can help me out.
Best,
Joyce

  0 件のコメント

サインイン to comment.

採用された回答

その他の回答 (1 件)

Ankit
Ankit 2019 年 9 月 26 日
There are different ways in which you can delete an element from your array
Case 1: If you want to delete an specific element
idx = index
a(idx) = []
Case 2: If you want to delete elements which have same value for e.g. 2
a = [1,2,3,2,5];
a(a == 2) = []
and other way as mentioned by madhan ravi

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。


Translated by