how to multiply a number to matrix?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Aarti Soni
el 18 de Jul. de 2022
Comentada: Bruno Luong
el 15 de Oct. de 2022
Hello everyone,
I have a matrix 180X360X1332 (Latitude X Longitude X Time). I want to multiply 30 at every fourth number of third demension (e.g., 1,5,9,13......1332)
I have tried this for vector data:
Y = 30*(1:4:1332);
How can I do this for matrix data?
Thanks
3 comentarios
Respuesta aceptada
vishweshwar samba
el 18 de Jul. de 2022
Editada: vishweshwar samba
el 18 de Jul. de 2022
I assume that the matrix 180X360X1332 (Latitude X Longitude X Time) is a multidimentional array and you want to multiply a value of 30 to (Latitude X Longitude) in the interval of 4 wrt Time.
% By using the below for loop, created a matrix 'A' of dimension 180x360x1332 (Latitude X Longitude X Time)
for i = 1:1332
A(:,:,i) = ones(180,360);
end
% Now multiply a number 30 in time dimension at interval of 4(1:4:1332)
A(:,:,1:4:1332) = A(:,:,1:4:1332)*30;
8 comentarios
Bruno Luong
el 15 de Oct. de 2022
@Aarti Soni I suggest you to create a new thread and better description. Someone else can answer to you.
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical 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!