How do you crete a function file?

조회 수: 1 (최근 30일)
Mark Davies
Mark Davies 2019년 12월 13일
편집: Dyuman Joshi 2023년 3월 20일
I need to create a function file that contains the commands to plot ? = sin ? and ? = sin2 ? on the same graph, I need to use the following expression to define the range of x in the function x=0:pi/A:2*pi. I then need to test the function using different values of A. Does this make sense?

채택된 답변

Dyuman Joshi
Dyuman Joshi 2019년 12월 14일
편집: Dyuman Joshi 2023년 3월 20일
Write the code, for e.g.
function y=graphplot(A)
x=0:pi/A:2*pi;
plot(x, sin(x))
hold on
plot(x, sin(2*x))
hold off
end
Call the function in the command window with an arbitary value of 'A'
graphplot(100) and plotted graphs will come as output. Try to give large values of A to ensure smooth curvesa and make sure the file is saved as the same name as the function.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by