matrix - MATLAB - Plotting matrices of different size on same plot - error in plot function -


i importing data 3 files , parsing obtain time , voltage values each file. these values need plotted against each other on same plot.

the data held in total of 6 matrices, 1 time , 1 voltage each of 3 data sets.

matrix dimensions: matlab data sets: 1000x1, ltspice: 465x1, oscope: 2500x1.

matlab finds error in use of plot function:

plot(matlab_t,matlab_v,'k',ltspice_t,ltspice_v,'j',oscope_t,oscope_v,'g'); 

is issue because matrix dimension vary between independent , dependent sets?

full code script:

clear; clc;  %% import %read in files  matlab_t=dlmread('engr_222_project_1_data.csv',',',[16 0 1015 0]); matlab_v=dlmread('engr_222_project_1_data.csv',',',[16 1 1015 1]);   ltspice_t=xlsread('ltspicedata_excel.xlsx','a1:a465'); ltspice_v=xlsread('ltspicedata_excel.xlsx','b1:b465');  oscope_t=xlsread('oscope_data.xlsx','d1:d2500'); oscope_v=xlsread('oscope_data.xlsx','e1:e2500');  %% plot  plot(matlab_t,matlab_v,'k',ltspice_t,ltspice_v,'j',oscope_t,oscope_v,'g'); 

to plot multiple matrices on same plot, each matrix must have same dimensions. in case have 2 465 x 1 matrices, 2 1000 x 1 matrices, , 2 2500 x 1 matrices, matrices must have dimension 2500 x 1.

to increase dimensions of of smaller matrices, redefine matrix size , set empty cells equal zero.

this accomplished in following code:

matlab_t(2500,1)=0; matlab_v(2500,1)=0; ltspice_t(2500,1)=0; ltspice_v(2500,1)=0; 

complete code using fix:

clear; clc;  %% import %read in files  matlab_t=dlmread('engr_222_project_1_data.csv',',',[16 0 1015 0]); matlab_v=dlmread('engr_222_project_1_data.csv',',',[16 1 1015 1]);   ltspice_t=xlsread('ltspicedata_excel.xlsx','a1:a465'); ltspice_v=xlsread('ltspicedata_excel.xlsx','b1:b465');  oscope_t=xlsread('oscope_data.xlsx','d1:d2500'); oscope_v=xlsread('oscope_data.xlsx','e1:e2500');  % redefine matrices equal size   matlab_t(2500,1)=0;  matlab_v(2500,1)=0;  ltspice_t(2500,1)=0;  ltspice_v(2500,1)=0;   %% plot  plot(matlab_t,matlab_v,'k',ltspice_t,ltspice_v,'j',oscope_t,oscope_v,'g'); 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -