Perform calculations on matrices stored in cells

2 views (last 30 days)
M
M on 31 Mar 2022
Answered: Stephen23 on 31 Mar 2022
How can I do the following calculations on 128 matrices each with 14*14 size which are stored in cells??
I want to calculate the Norm of( the difference between the 1st, 2nd and 3rd values from the first column of matrix No.128 and the 1st, 2nd and 3rd values from the first columns of each matrix) then divide it over the Norm of (the 1st, 2nd and 3rd values from the first column of matrix 128)
And Same to the 2nd and 3rd columns
I mean:
taking the Norm of( the difference between the 1st, 2nd and 3rd values from the 2nd column of matrix No.128 and the 1st, 2nd and 3rd values from the 2nd columns of each matrix) then divide it over the Norm of (the 1st, 2nd and 3rd values from the 2nd column of matrix 128)
Same for the 3rd column
Then store the obtained 3 values that calculated from each column of each matrix in columns as a one matrix.

Answers (2)

Torsten
Torsten on 31 Mar 2022
help cell2mat

Stephen23
Stephen23 on 31 Mar 2022
A = cat(3,C{:}); % join all matrices into one array
A(1:3,1,128) - A(1:3,1,:) % difference 1st column
A(1:3,2,128) - A(1:3,2,:) % difference 2nd column
A(1:3,3,128) - A(1:3,3,:) % difference 3rd column
You should be able to figure out the division, norms, etc.

Categories

Find more on Creating and Concatenating Matrices 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!