Keeping the dimension of the matrix but finding values greater than 0.1, and putting them in new matrix

StackOverflow https://stackoverflow.com/questions/23500537

  •  16-07-2023
  •  | 
  •  

Domanda

i have a small problem. i have a 3D matrix, and i want to seperate values greater than 0.1 into a new matrix, but keep the dimentions intact.. Because it is 24x45x65. and 24 = hours, 45 = days and 65 = customers. is it possible? i used find() no luck..i used x_weekday(x_weekday > 0.1) i get the values greater than 0.1 but all in 1 column..and it destroys the dimention.

help please.

i have attached the file as link if need be. file: x_weekday.mat

È stato utile?

Soluzione

Approach 1:

%%// new_x_weekday would be the one you are after, assuming you want to 
%%// keep the rest of the data that are not greater than 0.1 to be 0

new_x_weekday = zeros(size(x_weekday))
new_x_weekday(x_weekday>0.1) = x_weekday((x_weekday>0.1))

Approach 2:

new_x_weekday = x_weekday;
new_x_weekday(new_x_weekday<=0.1)=0
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top