add to values in a varying size cell array
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I would like to add 15 to the values in CB that match up with the -10s in CA. (i.e. 17, 4, and 7)
CA = {[-10 2],[6 6 8],[0 9 -10 8 -10]};
CB = {[17 2],[6 6 10],[9 3 4 9 7]};
idx = cellfun(@(x)any(x(:)==-10),CA) & not(cellfun(@(x)any(x(:)==-10),CB)); % Not sure if I am on the right track with this.
0 comentarios
Respuestas (1)
KSSV
el 1 de Mayo de 2019
CA = {[-10 2],[6 6 8],[0 9 -10 8 -10]};
CB = {[17 2],[6 6 10],[9 3 4 9 7]};
for i = 1:length(CA)
idx = CA{i}==-10 ;
CB{i}(idx) = CB{i}(idx)+15 ;
end
3 comentarios
Ver también
Categorías
Más información sobre Cell Arrays en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!