What is the syntax to access a particular member in an array?
古いコメントを表示
Hi, I have an array x=[1 2 3 4 5].
I then manipulate x, e.g. (A*x/B+C-D)...How can I determine the third member of the manipulated array?
This works but i feel there is a simpler way:
temp=(A*x/B+C-D);
temp(3)
Is there a way to do something like
(A*x/B+C-D)(3)?
1 件のコメント
Azzi Abdelmalek
2014 年 7 月 29 日
編集済み: Azzi Abdelmalek
2014 年 7 月 29 日
There is no simpler way. I think also that you tried what you are asking about and it didn't work
採用された回答
その他の回答 (1 件)
Michael Haderlein
2014 年 7 月 29 日
Actually, I sometimes also don't want to assign some intermediate result to an extra variable. Tucker McClure has included a function in his collection of functional programming constructs which I use in this case:
>> x=1:5;
>> paren(x.^2,3)
ans =
9
3 件のコメント
Rainer
2014 年 7 月 29 日
Image Analyst
2014 年 7 月 29 日
Just gives an error for me:
>> x=1:5;
>> paren(x.^2,3)
Attempt to execute SCRIPT paren as a function:
C:\Program Files (x86)\MATLAB\R2014a\toolbox\matlab\ops\paren.m
Michael Haderlein
2014 年 7 月 30 日
Have you downloaded the collection I have linked? According to your error message, Matlab doesn't find the paren function.
Even if you don't want to use this particular function: there are lots of helpful little functions included, it's really worth a look in my opinion.
カテゴリ
ヘルプ センター および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!