- Use the “rescale” function provided by MATLAB to scale the values between any given range [a,b]. You can read more about the “rescale” function using the following MathWorks documentation link: https://www.mathworks.com/help/matlab/ref/rescale.html
- Otherwise, you can use the calculated mean and standard deviation to scale the values as shown below.
How to normalize the values of a dataset of 32X8X2X15000 in the range -0.5 to 0.5 using standard deviation
    6 次查看(过去 30 天)
  
       显示 更早的评论
    
If I have dataset  of 4D  single with size 32X8X2X15000. And I have calculated the mean and standard deviation of thart particular dataset. Now I want to bring all the values of the dataset within the range -0.5 to 0.5. How to do that
0 个评论
回答(1 个)
  Udit06
      
 2023-8-29
        Hi Anusaya, 
I understand that you are trying to scale your data present in the 4-D matrix so that it falls in the range [-0.5, 0.5]. You can try out the following two approaches to scale your data: 
% Assuming your dataset is stored in a variable called 'data' 
data = rand(32, 8, 2, 15000) % your 4D dataset with size 32x8x2x15000 
% Calculate the mean and standard deviation 
mu = mean(data(:)); 
sigma = std(data(:)); 
% Normalize the dataset within the range -0.5 to 0.5 
normalized_data = (data - mu) / (2 * sigma); 
normalized_data = normalized_data * 0.5; 
% Clip values outside the range -0.5 to 0.5 
normalized_data = max(min(normalized_data, 0.5), -0.5); 
% Verify the range of the normalized data 
min_val = min(normalized_data(:)); 
max_val = max(normalized_data(:)); 
disp(['Minimum value: ', num2str(min_val)]); 
disp(['Maximum value: ', num2str(max_val)]); 
I hope this helps. 
0 个评论
另请参阅
类别
				在 Help Center 和 File Exchange 中查找有关 Statistics and Machine Learning Toolbox 的更多信息
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

