semilogy several plot with correction factor in matlab

You can use the semilogy function to plot data on a logarithmic y-axis. To plot several lines on the same figure with a correction factor, you can specify each line's data as a matrix and apply the correction factor after importing. Here is an example:

main.m
% Input data
x = 1:10;
y1 = [10 20 30 40 50 60 70 80 90 100];
y2 = [50 100 150 200 250 300 350 400 450 500];

% Apply correction factor
corr = 0.1;
y1c = y1 * corr;
y2c = y2 * corr;

% Plot
figure;
semilogy(x, y1c, 'b', x, y2c, 'r');
xlabel('x');
ylabel('y corrected');
legend('Line 1', 'Line 2');
298 chars
17 lines

In this example, we first define our input data for x, y1, and y2. We then apply a correction factor of 0.1 to each line using element-wise multiplication. Finally, we plot both lines on the same figure using semilogy, with a legend to differentiate between the two.

related categories

gistlibby LogSnag