clc;
close all;
clear;
workspace;
format long g;
format compact;
fprintf('Beginning to run %s.m ...\n', mfilename);
x = [...
0.0 14.96 15.94
0.2 14.98 15.91
0.4 13.47 15.94
0.6 10.90 13.66
0.8 5.60 12.38
1.0 0.00 7.84
1.2 0.00 2.35
1.4 0.00 0.51 ]
[rows, columns] = size(x);
cmap = jet(rows);
labelStrings = cell(rows, 1);
for row = 1 : rows
thisXAxis = linspace(x(row, 2), x(row, 3), 500);
period = x(row, 1);
amplitude = rand;
y = amplitude * cos(2 * pi * thisXAxis / period);
plot(thisXAxis, y, '-', 'Color', cmap(row, :), 'LineWidth', 4);
grid on;
hold on;
legendStrings{row} = sprintf('Curve %d', row);
end
fontSize= 20;
xlabel('X', 'FontSize', fontSize);
ylabel('Y', 'FontSize', fontSize);
legend(legendStrings, 'Location', 'north');
g = gcf;
g.WindowState = 'maximized';
fprintf('Done running %s.m.\n', mfilename);
2 Comments
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/725767-generating-a-range-of-curves-that-fit-inside-a-set-of-fixed-limits#comment_1283247
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/725767-generating-a-range-of-curves-that-fit-inside-a-set-of-fixed-limits#comment_1283247
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/725767-generating-a-range-of-curves-that-fit-inside-a-set-of-fixed-limits#comment_1283672
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/725767-generating-a-range-of-curves-that-fit-inside-a-set-of-fixed-limits#comment_1283672
Sign in to comment.