How Can I Plot f(n*x)
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Mahsa Babaee
am 24 Okt. 2021
Kommentiert: Mahsa Babaee
am 25 Okt. 2021
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.
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 25 Okt. 2021
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;
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Get Started with MATLAB finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!