Replacing symbolic vector with changing values

I have a symbolic vector with repeating entries, similar to:
(cos(x), cos(x), cos(x), cos(x+5), cos(x+5)...)
and what i want to do is replace x with incrementing values so I can plot it. I have tried subs but it does not work properly. If my vector is the one i defined, i want my result to be
(cos(1), cos(2), cos(3), cos(4+5), cos(5+5)...)
but evaluated so that I may graph it. Is there a simple way to do this? I wrote an EXTREMELY inefficient loop that accomplished this by substituting the variable for the entire vector then storing only the necessary element into an output array, but it cannot handle the size i need.
Thanks

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 1 月 12 日
編集済み: Azzi Abdelmalek 2013 年 1 月 12 日

1 投票

syms x
y=[cos(x), cos(x), cos(x), cos(x+5), cos(x+5)]
out=arrayfun(@(x) eval(y(x)),1:numel(y))

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLabels and Annotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by