Scaling data to become withing a smaller range [duplicate] - matlab

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
MATLAB: how to normalize/denormalize a vector to range [-1;1]
I'm designing a Neural Network. As you know the inputs are preferred to be small, like between (0,1) or (-1,1). My data is in the range (1,9) .. how can I scale it to become within (-1,1) ?
I know I can use a Sin function, but I'm not sure if that's correct .. is there another way ?

Find the minimum and maximum of your data, and then for each data point, subtract the minimum and divide by (max-min). This is called normalization-- all your inputs will be in the range 0-1

Related

how to find nearest grid points in the set of data points using matlab [duplicate]

This question already has an answer here:
Bilinear image interpolation / scaling - A calculation example
(1 answer)
Closed 6 years ago.
I have (x,y) points and how to find (x1,y1),(x1,y2),(x2,y1),(x2,y2) grid points in the set of data points(xi,yi)...
Have a look at ceil and floor.
They will round up and down a value, thus ceil(3.2) will output 4 and floor(3.2) will output 3. The right combinations of ceil/floor x and y will give all the points you need.

Upsampling and downsamling of 3D-volume in all 3 dimensions [duplicate]

This question already has answers here:
resizing 3D matrix (image) in MATLAB
(3 answers)
Closed 6 years ago.
Is there any function for computing expansion and reduction for 3D images in matlab? For example, something to reduce 3D-volume from 170*240*240 to 85*120*120 or to expand from 85*120*120 to 170*240*240.
'impyramid' in matlab does similar but only reduce and expand in the first 2 dimension.
I also saw this function https://www.mathworks.com/matlabcentral/fileexchange/12037-gaussian-pyramid-expand-and-reduce-routines-1d--2d-and-3d on mathworks file exchange but it is relatively slow for 3D-volume.
Memory expensive and slow way to do it, and probably the only way of really doing it:
% Desired size
sz=[120 , 56, 123]; %whatever
[y, x, z]=...
ndgrid(linspace(1,size(img,1),sz(1)),...
linspace(1,size(img,2),sz(2)),...
linspace(1,size(img,3),sz(3)));
imOut=interp3(img,x,y,z);
clear x y z
You can save some time (or expend more!) by providing a method to interp3.
nearest will be cheaper but less accurate. The rest more expensive computaionally.

How to measure the closeness in the values of two vectors of different lengths [duplicate]

This question already has answers here:
Calculate distance between two vectors of different length
(4 answers)
Closed 7 years ago.
How can I measure the closeness in the values of two vectors of different lengths ?
The formula for distance of two vectors of different length is explained here:
Calculate distance between two vectors of different length

Histogram normalise figure output [duplicate]

This question already has an answer here:
Centering histogram bins and setting percentage range in Matlab
(1 answer)
Closed 9 years ago.
I have a big matrix with thousands of values. I want to make a histogram of each signal. This is easily done with MALTAB's commands. My problem is I want it normalised in the sense that the y-axis is 0-1 and not 0-(the number of measurements). Any smart way to do this?
Use histc()
counts = histc(data);
normCounts = counts/sum(counts);

how to fit a gaussian to the data points in matlab [duplicate]

This question already has answers here:
How to fit a gaussian to data in matlab/octave?
(4 answers)
Closed 8 years ago.
I am doing k means on data points and want to fit data points into Gaussian to help me form
clusters.i have tried to some but not able to do. may someone tell me how to fit Gaussian in Matlab???
if you want to fit a Gaussian to any data, you must keep in mind that
a Gussian is simply f(x) =f_0 exp( - (x-x0)^2 /a ). Take Log_e of your data and fit a parabola! This is possible because,
log [ f(x) ]= log f_0 - (x-x0)^2 /a