Interpolate values to the nearest 0.25 and create indices for these values
6 views (last 30 days)
Show older comments
I have multiple matrices that I am trying to combine, so I need to tranform data into positive integers.
Code to create the example 2D matrix:
Cap=10;
x=linspace(1,Cap,Cap)';
F = 10;
p = 7;
b = [(1./(1+(exp(p-x))))];
SO = [0.75];
Rsb = [F*b*SO];
Rss = [0*x];
RNO = [Rss Rbb];
Which I make into a 3D matrix such as rp1 below:
rp1 = RNO;
R0 = [Rss Rss];
rp1(:,:,2) = R0;
This matrix contains a lot of zeros and values with several decimal places.
I am trying to use a linear interpolation (rather than actually rounding) to get these decimals to the nearest 0.25. I have no idea how to do this!
I then would like to take these values, to the nearest 0.25 (and all the zeros!) and create an index for these values -- so I can convert between the indices and the actual values, and so my matrices consist of all positive integers so I can add them. To do this, I believe I would need some number of categories that these values fall into. Values across matrices run from 0 to 8, so I believe once I have them to the nearest 0.25 I'll have 32 categories. After this, I'm at a total loss!
I greatly welcome and appreciate any and all help!
3 Comments
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!