Merge a piecewise, parameterized Function

2 ビュー (過去 30 日間)
Georg Söllinger
Georg Söllinger 2016 年 10 月 24 日
コメント済み: Georg Söllinger 2016 年 10 月 24 日
Hello dear community,
I am dealing with the following problem: I have a three-piece parameterized 2D function (one straight line followed by a circular segment followed by another straight line). The Parameterization is done with a t, which has an increment of say 1mm. What I would like to have is a merged parameterized function, where I have all the seperate functions in one equations. But the problem is the increment. I thought about some kind of logical operator like Föppl Bracks (if the entity is true, then the term in the brack is =1, if false, than =0) but I cannot find anything like that in the matlab documentation.
The alternate way would be to manage the whole thing with three if's containing the parameterized segments, which is not as handy as one single function.
Does anyone have an idea or a solution for my problem? Help is truly appreciated!
Thanks, Georg

採用された回答

Thorsten
Thorsten 2016 年 10 月 24 日
You can use logical indexing
x = 1:100;
y = [sin(x(x <= 20)) cos(x(x>20 & x <= 40)) tan(x(x>40))];
  1 件のコメント
Georg Söllinger
Georg Söllinger 2016 年 10 月 24 日
Okay, that was, what I was looking for. But then, there is another issue: If I define a function as follows:
geo = @t t(t<length_a) + radius * cos(t(t>=length_a & t<length_b)/radius);
with length_a, length_b being the boundaries of the piecewise functions, I get the following Error: Error using + : Matrix dimensions must agree.
Where is my mistake?

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by