Saturating Functions at a certain value

How do you saturate a function at a certain value on matlab? say for example I have the array x=[0:0.01:20] and the function expo=2.^x, and I want to plot the function expo with respect to x but I want the values to saturate when it reaches 1000 and remain equal to 1000 until the end of the array, looked up a bunch of stuff but all of it was useless.

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2020 年 5 月 22 日

0 投票

x=[0:0.01:20];
expo=@(x) min(2.^x,100);
plot(x,expo(x));

4 件のコメント

Momen Elhassan
Momen Elhassan 2020 年 5 月 22 日
much appreciated, if it's not too much trouble how do you tweak that code to instead saturate a lower limit instead of an upper one.
Fangjun Jiang
Fangjun Jiang 2020 年 5 月 22 日
help min
help max
Momen Elhassan
Momen Elhassan 2020 年 5 月 22 日
thanks
Walter Roberson
Walter Roberson 2020 年 5 月 22 日
max(lower_limit, min(YourArray, upper_limit))

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

カテゴリ

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

製品

質問済み:

2020 年 5 月 22 日

コメント済み:

2020 年 5 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by