-1

I'm trying to change the matrix index, by storing values, but I'm not quiet sure how to do it.

I have a matrix imported from Excel, where the values in the first row and column indicating a week number and a zip code. So when I call the function in command window, I would like to be able to write week number and zip code as parameters, instead of the matrix index. Is that possible? And how?

Thank you

1 Answers1

1

You can probably do it with a function like this:

function value = GetValue(matrix, date, zipcode)
    r = find(matrix(:, 1) == date);
    c = find(matrix(1, :) == zipcode);
    value = matrix(r,c);
end
Dan
  • 45,079
  • 17
  • 88
  • 157
  • Thanks, but what if I wish to use While to run through the column with zip codes, and find the matrix index for the zip code I type in my call. Would that be possible and how? Thank you – Nanna Larsen Jun 10 '13 at 19:18
  • @NannaLarsen I don't understand your question I'm afraid. With this function you can just enter a date and a zip code and pull out the relevant cell? Is that not what you are trying to do? – Dan Jun 11 '13 at 06:49