Plot with smaller variation in input argument under user defined function?

1 回表示 (過去 30 日間)
Muhammad Usman
Muhammad Usman 2021 年 2 月 5 日
回答済み: Srivardhan Gadila 2021 年 2 月 8 日
I am stuck with a smaller concept that How to Plot with smaller variation in input argument under user defined function?
For example I have a function:
function ques(x,del_x)
xx = x+del_x;
t = sin(xx);
plot(xx,t,'-');
end
my input has 2 aruguments with values
x = -pi:pi/100:pi;
del_x = eps/pi;
First of all I want to plot x and del_x =0 then on the same plot (window) I want x and del_x mentioned above. hold on is not working when I execute this code with different values in command window.
Looking for help.
Thanks

回答 (1 件)

Srivardhan Gadila
Srivardhan Gadila 2021 年 2 月 8 日
"hold on is not working when I execute this code": It's probably because the the value of del_x is very small and it is difficult to see the impact. Try changing the value of del_x to higher values and then you can see that "hold on" works properly.
>> x = -pi:pi/100:pi;
>> del_x = pi/2;
>> ques(x,0)
>> hold on
>> ques(x,del_x)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by