How to work with 3D Matrix

1 Ansicht (letzte 30 Tage)
Onovo
Onovo am 18 Feb. 2016
Bearbeitet: Stephen23 am 18 Feb. 2016
Please am new to programming, and have just generated a 3 dimensional matrix of Q [Q] with size 1000X24X3 using the cfollowing matlab command,
clear all;
clc;
N = 3;
A = rand(1000,N*3);
for i=1:N
Q(:,:,i)= A(1:1000,(24*(i-1)+1):i*24)
end
From my code above I can vary the size of my 3D matrix Q by varying N. Now I want to sum and as well impose certain conditions on my 3D matrix such that;
since N=3, and I have partial matrix Q(:,:,i) in 3D matrix Q (size 1000X24XN), where i=1:N. I want sum every element on each row of the partial matrix, such that any rows whose summed value is greater than lets say 16, each element in that row of the partial matrix should be multiplied 16 and then divided by the value of their sum. This is to ensure that sum of the element in each row of respective partial matrix is less than 16.
Also I want to sum all the element in each row of the 3D matrix and ensure their sum does not exceed lets say 40, such that any row whose total elements sum is greater than 40, all the element in that row should be divided by their summed value and then multiplied by 40. this would ensure the sum of all elements in row of my 3D matrix does not exceed 40.
I would be grateful if anyone can provide useful information. Thank you.

Antworten (0)

Kategorien

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

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by