Scale 3D matrix by 10i
1 回表示 (過去 30 日間)
古いコメントを表示
M = randi([5 10], 1);
N = randi([5 10], 1);
P = randi([20 30], 1);
Y = round(-10 + (10 - (-10)).*rand(M, N, P));
===================================
indexes = 1:P;
scaling = repmat(indexes(:), [M, N, P])
Yscaled = Y.*(scaling.*10)
How I understand this question is that I have to create another 3D matrix and multiple the two (matrix) in order to scale it
How to I create a 3D matric: first page all 1 , second page all 2 , etc up to P
0 件のコメント
回答 (3 件)
Image Analyst
2014 年 1 月 26 日
編集済み: Image Analyst
2014 年 1 月 26 日
Hint:
y=cat(3, ones(2), 2*ones(2), 3*ones(2)) % Sample initial data.
[rows, columns, planes] = size(y)
m = 10*(1:planes)
m2 = imresize(m', [numel(y), 1], 'nearest')
y_out = reshape(.......
Finish the last line by yourself and it will be done. imresize() requires the Image Processing Toolbox. Type ver to see if you have it.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!