Clear Filters
Clear Filters

How to show two plots on same graph?

1 view (last 30 days)
Ismaeel Dasti
Ismaeel Dasti on 26 Nov 2018
Commented: Ismaeel Dasti on 26 Nov 2018
I am reading 2 sets of data from my computer and would like to show the plots for both sets of data on one graph. I am using the hold on command but the plots still show on separate graphs. How can I fix this? Code shown below.
clear all; close all; clc; format compact
% Define parameters of circuit
R = 100e3 % Update according to resistor used in circuit
C = 10e-6
tau = R*C
% Load in data
% OPTION 1: If loading file from your local machine:
% A = csvread('data.csv',2,1);
% OPTION 2: If using MATLAB via Virtual Computing Lab, identify folder on your laptop:
A = csvread('data4.csv',3,1);
A2 = csvread('data3.csv',3,1);
% Extract and assign data
V1 = A(:,1);
V2 = A(:,2);
t = A(:,3);
V3 = A2(:,1);
V4 = A2(:,2);
t2 = A2(:,3);
% Plot data
figure(1);hold on
plot(t,V1,'r','LineWidth',4)
plot(t,V2,'g','LineWidth',4)
hold on
figure(2);hold on
plot(t2,V3,'b','LineWidth',4)
plot(t2,V4,'c','LineWidth',4)
title('Title here');
grid minor
legend('V1','V2','Location','NorthEast')
title('Analysis of RC Circuit Data')
xlabel('Time [sec]')
ylabel('ADC Code')

Answers (1)

madhan ravi
madhan ravi on 26 Nov 2018
An example:
plot(x,y)
hold on
plot(x1,y1)

Categories

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

Community Treasure Hunt

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

Start Hunting!