iterating A Function

2 visualizaciones (últimos 30 días)
Alex
Alex el 15 de Feb. de 2012
Editada: Matt J el 13 de Oct. de 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.

Respuesta aceptada

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by