How to subtract coloumn vectors of a cell array
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dear Community,
I have a cell array, with each cell containing n by m matrix. I would like to use cellfun and minus, and subtract the first coloumn from the second one, and add the value of 1. (like: result=(second coloumn-first coloumn)+1)
Unfortunately I do not exacty understand the nature of cellfun, to solve this.
Please find attached an example cell, and a result.mat showing, what would I like to get, when perform the calculation in the first cell.
Many thanks for you suggestions!
lg
0 commentaires
Réponses (1)
Stephen23
le 26 Sep 2021
inp = load('mycell.mat').mycell; % input data
fun = @(m) 1+diff(m,1,2); % anonymous function
out = cellfun(fun,inp, 'uni',0) % calculate
out{1} % compare first cell against expected output
load('result.mat').result
0 commentaires
Voir également
Catégories
En savoir plus sur Cell Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!