How can I create a 3D matrix?
74 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
chia ching lin
el 2 de Dic. de 2020
Comentada: KALYAN ACHARJYA
el 2 de Dic. de 2020
I got three matrix,
num1=linspace(0,1,100);
num2=linspace(0,1,100);
num3=linspace(0,1,100);
how can combine them together to become a 3D matrix ? (formed like below)
(or maybe what I want doesnt called a 3D matrix)?
w is the final matrix i wanted.
>> w(1,1,1)
ans = 0 0 0
>> w(2,1,1)
ans = 0.01 0 0
>> w(100,1,1)
ans = 1 0 0
>> w(2,1,2)
ans = 0.01 0 0.01
>> w(:,1,1)
ans = 0 0 0
0.01 0 0
0.02 0 0
0.03 0 0
...
Or maybe what I want doesnt called a 3D matrix? Any function or keyword I can look up for?
0 comentarios
Respuesta aceptada
KALYAN ACHARJYA
el 2 de Dic. de 2020
Editada: KALYAN ACHARJYA
el 2 de Dic. de 2020
mat_3d=rand(rows_num,columns_mum,depth);
Here depth represents channel number/number of plane slices
Your query ('how can combine them together to become a 3D matrix ?')
num1=linspace(0,1,100);
num2=linspace(0,1,100);
num3=linspace(0,1,100);
result=cat(3,num1,num2,num3);
2nd part:
w(1,1,1)
ans = 0 0 0
For such a case you may look at a multi dimentional cell array for an array stored in a single location. In a multi-dimensional matrix, using w(rows, columns, channel_number) only gives single numeric value. Yes, if you use range numbers or column numbers or ranges of channel numbers, you may get an array as a result.
2 comentarios
KALYAN ACHARJYA
el 2 de Dic. de 2020
"I'm tyring to built a 256x256x256 RGB"
It suppose to have 256 gray planes (Multi dimentional 3 D arrays ), right? Here is the example
result=zeros(256,256,256);
for i=1:256
result(:,:,i)=rand(256,256);
end
Check:
>> whos result
Name Size Bytes Class Attributes
result 256x256x256 134217728 double
Más respuestas (0)
Ver también
Categorías
Más información sobre Multidimensional 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!