Equating and plotting the ratio of two sets of data having unequal length.

2 views (last 30 days)
Hello, I'm a beginner in matlab. I'm having problem in plotting a graph on matlab. I want to plot curve2:curve1. curve1 and curve2 has unequal length nad also the x axis is unequal. kindly help me.
curve1 curve2
x y x y
100 50 100.1 30
200 70 100.4 20
200.5 60 100.5 40
300 20 200 50
400 90

Answers (1)

Andy
Andy on 20 Oct 2020
In the simplest form, create variables for the two curves:
data1 = [100 200 200.5 300 400;50 70 60 20 90];
data2 = [100.1 100.4 100.5 200;30 20 40 50];
% Plot the first data set with a blue line
plot(data1(1,:),data1(2,:),'b')
% Tell Matlab to keep plotting curves on the same Figure
hold on
% Plot the second data set using a red curve
plot(data2(1,:),data2(2,:),'r')
If you examine the help for plot you will find out how to set other parameters for the graph.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!