Help regarding iterations when a specific table of values has to be used.

1 view (last 30 days)
i am trying to do the iterations for a blade design. i calculate the value of a certain variable 'x' value of which then corresponds to another value predefined in a table. for every iteration the value of 'x' changed and so does the other value. How can i incorporate the values in the table in to iterations? any and all help will be appreciated I was thinking to use if and else in the loop but i am having trouble matching the value of "x" in the table and using the corresponing value against it.

Accepted Answer

Image Analyst
Image Analyst on 18 Apr 2015
If you have x, find the row that x is in the table like this (I'm assuming we're going to look in column 1);
% Find the row in column 1 of yourMatrix where x occurs.
[~, row] = min(abs(yourMatrix(:, 1)) - x)
% Get the value of yourMatrix in that row.
% I'm going to assume we want to extract that value from column2.
outputValue = yourMatrix(row, 2);
If that's not what you meant then please clarify.
  1 Comment
qasim zia
qasim zia on 18 Apr 2015
this is exactly what i was looking for thank you. i will try this and see if solves my problem (which i hope it will) :)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!