How Can I Plot f(n*x)

조회 수: 5 (최근 30일)
Mahsa Babaee
Mahsa Babaee 2021년 10월 24일
댓글: Mahsa Babaee 2021년 10월 25일
Dear experts, Hi
Unfortunately I faced difficulties in function plotting. I am apreciated If anybody could guide me how to plot when and & for instance.

채택된 답변

Image Analyst
Image Analyst 2021년 10월 25일
Assuming it's not your homework (because you'd get into trouble for submitting our code as your own), try this:
x = linspace(1, 5, 500); % Only 5 elements if we step by 1 so use more to get a smooth curve.
numberOfSums = 10;
Lx = 10 % A scalar.
n = 1 : numberOfSums % 10 elements
omega = n .* pi / Lx % 10 elements
for k = 1 : numberOfSums
thisOmega = omega(k);
fprintf('Building curve #%d of %d with omega = %.4f...\n', k, numberOfSums, thisOmega);
thisCurve = sin(thisOmega .* x);
if k == 1
fx = thisCurve;
else
fprintf(' Summing in curve #%d of 10 to the master curve...\n', k);
fx = fx + thisCurve;
end
end
plot(x, fx, 'b-', 'LineWidth', 2);
grid on;
  댓글 수: 1
Mahsa Babaee
Mahsa Babaee 2021년 10월 25일
Thank you so much! Your guidances were helpful.
P.S. It's not my homework. You can rest assured!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by