iterating A Function

2 visualizzazioni (ultimi 30 giorni)
Alex
Alex il 15 Feb 2012
Modificato: Matt J il 13 Ott 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.

Risposta accettata

Benjamin Schwabe
Benjamin Schwabe il 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 Commento
Alex
Alex il 15 Feb 2012
Thanks for your help! It worked perfectly.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by