Using a statement to identify a specific matrix with a given range of values.

1 view (last 30 days)
I am hoping to get some help with a question concerning using a value range in MatLab. I am trying to write a statement where if the value of a variable falls within a given range, than a specific table of values is selected.
I am using the following code to round values for atmosT and RH:
roud_atmosT = round(atmosT);
roud_RH = round(RH);
and have the following selection of matrices: x15C_ab, x17_5C_ab, x20C_ab, x22_5C_ab, x23C_ab
so for example, "if the value for roud_atmosT is 15 to 17, than ambient_T = 'x15C_ab'
Let me know if you need any more info or further explanation/definition. Thanks for any help you can give.

Accepted Answer

Orion
Orion on 16 Oct 2014
Edited: Orion on 16 Oct 2014
Hi,
for what I understand, you need something like
if roud_atmosT>=15 || roud_atmosT<=17
matrix_name = sprintf('x%dC_ab',roud_atmosT);
ambient_T = eval(matrix_name);
end
and then add some else if cases for all your values.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!