How do I access an element of an array of equations
1 回表示 (過去 30 日間)
古いコメントを表示
This is the code I want to work
a = @(x) 3*x;
b = @(x) 5*x;
y =@(x) a(x):x:b(x);
y = y(x);
y(1)
a and b are functions of x so I want y to be 3x, 4x, 5x and I want to be able to acces an element (ex: 4x) but I can't figure out the syntax
0 件のコメント
回答 (1 件)
John D'Errico
2022 年 11 月 22 日
If x is symbolic, you CANNOT use it in a colon call. But in the end, you did not ask for a symbolic result, but a function of x.
So trivially, you can do this:
a = @(x) 3*x;
b = @(x) 5*x;
y = @(x) (a(1):b(1))*x;
y(1)
y(3)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrices and Arrays についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!