Filter löschen
Filter löschen

How to insert value in a specific row and column of cell array ?

6 Ansichten (letzte 30 Tage)
Rasa
Rasa am 12 Mär. 2019
Beantwortet: madhan ravi am 12 Mär. 2019
I have a 1 * 3 cell. The first two elements {1,1} and {1,2} contains random numbers from 1 to 500. So they are of the size : 500 * 1 each.
I want my {1, 3} element to have this value -> First to check if the {1,2} row contains the number 100, 200, 300, 400 and 500. If it does, I want to add value '1' in the corresponding row. If it does not have those numbers, I want to add value '0'. How do I achieve this ? How do I add value '1' at the exact same row corresponding to the those numbers (100, 200, 500 etc) ?

Antworten (2)

KSSV
KSSV am 12 Mär. 2019
A = [100 50 600 500 35 20 300 100 200 500 600] ;
idx = A==100|A==200|A==500

madhan ravi
madhan ravi am 12 Mär. 2019
idx=ismember(A,[100,200,500])

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by