iterating A Function

5 views (last 30 days)
Alex
Alex on 15 Feb 2012
Edited: Matt J on 13 Oct 2013
Hey all, quick question:
Say I have some data:
a,b,c
2,3,4
5,6,7
8,9,10
And an equation:
0=((a-b)./c)-R
and I want to solve for R for each of the rows of data, how would I create an iteration for that? I can call the data from a .csv file, and output the results as well, but I've never set up an iteration myself. As a side note, the data may have x variables (columns) and I may need to iterate n number of times.
Thanks.

Accepted Answer

Benjamin Schwabe
Benjamin Schwabe on 15 Feb 2012
I'm not sure if that's really what you want to have:
Define a matrix
A=[2,3,4;5,6,7;8,9,10];
R=((A(:,1)-A(:,2))./A(:,3));
Results for your axample are:
R =
-0.2500
-0.1429
-0.1000
If you want to use a csv file, please have a look at the command csvread.
I hope this answers your question.
  1 Comment
Alex
Alex on 15 Feb 2012
Thanks for your help! It worked perfectly.

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!