iterating A Function

2 ビュー (過去 30 日間)
Alex
Alex 2012 年 2 月 15 日
編集済み: Matt J 2013 年 10 月 13 日
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.

採用された回答

Benjamin Schwabe
Benjamin Schwabe 2012 年 2 月 15 日
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 件のコメント
Alex
Alex 2012 年 2 月 15 日
Thanks for your help! It worked perfectly.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by