フィルターのクリア

How to Stretching and shrinking a graph

53 ビュー (過去 30 日間)
Antonella
Antonella 2013 年 10 月 30 日
コメント済み: Antonella 2013 年 10 月 30 日
I have the function y = sin(x) and i have to stretching the graph of it. I have also to shrinking it. How can i write this in matlab?
x = 1:.01:10; y = sin(x); for i = 1 : length(y)
how i have to continue...???
Thanks in advance!!!
  1 件のコメント
sixwwwwww
sixwwwwww 2013 年 10 月 30 日
What do you mean by stretching or shrinking? and also by the "sin" is a built-in function in MATLAB so don't use as name of your function. Do you want to input some scaling factor as input in you code and want out be scaled accordingly?

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

回答 (2 件)

sixwwwwww
sixwwwwww 2013 年 10 月 30 日
編集済み: sixwwwwww 2013 年 10 月 30 日
Beside the comment you can do something like this:
scaling_factor = 2; % define the scaling factor and graph will scale accordingly
x = 1:.01:10 * scaling_factor;
y = sin(x);
figure, plot(x, y), title(strcat('Scaling factor = ', num2str(scaling_factor)))
I hope it helps. Good luck!
  1 件のコメント
Antonella
Antonella 2013 年 10 月 30 日
Thanks really much for this help! ;)

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


Wayne King
Wayne King 2013 年 10 月 30 日
You can simply dilate the independent variable in the function
x = 0:0.01:10;
y = sin(x);
y2 = sin(x/2);
plot(x,y); hold on;
plot(x,y2,'r')
To shrink the function:
y3 = sin(2*x);
plot(x,y3,'k')
  1 件のコメント
Antonella
Antonella 2013 年 10 月 30 日
Thanks very much for your availability and your help! ;)

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

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by