setting up a step function
古いコメントを表示
I'm trying to do this step function, the final goal is to plot Gabriel's cake. x goes from 0 to 8. f(x)=1/n if n<=x<n+1. I'm not sure how to do this. I'm guessing the if command but I'm not sure how to do it. Any help is appreciated. Thank You.
3 件のコメント
Sean Smith
2011 年 10 月 1 日
Fangjun Jiang
2011 年 10 月 3 日
What is Gabriel's cake? You have a function f(x) as x is the input variable, what is n? How is it related to x?
Sean Smith
2011 年 10 月 3 日
採用された回答
その他の回答 (1 件)
Rick Rosson
2011 年 10 月 2 日
>> doc floor
6 件のコメント
Sean Smith
2011 年 10 月 2 日
Walter Roberson
2011 年 10 月 2 日
x = 1:.01:8;
plot(x, 1/floor(x))
Sean Smith
2011 年 10 月 2 日
Walter Roberson
2011 年 10 月 3 日
What differences do you see between what you are looking for and what you get ? I do not have access to MATLAB itself at the moment, but when I plot in a different package, the result looks like what I would expect. Or is the problem merely with the end condition? Do you want it to end just _before_ 8, or right _at_ 8 (which would be 1/8), or do it want it to end just _before_ 9, or what ?
Sean Smith
2011 年 10 月 3 日
Walter Roberson
2011 年 10 月 3 日
The code given is the code for the function you describe, which is the same function described in http://www.maa.org/pubs/Calc_articles/ma044.pdf
カテゴリ
ヘルプ センター および File Exchange で Programming についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!