iterating A Function

2 vues (au cours des 30 derniers jours)
Alex
Alex le 15 Fév 2012
Modifié(e) : Matt J le 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.

Réponse acceptée

Benjamin Schwabe
Benjamin Schwabe le 15 Fév 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 commentaire
Alex
Alex le 15 Fév 2012
Thanks for your help! It worked perfectly.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by