Azzera filtri
Azzera filtri

How can i verify time step of excel files?

3 visualizzazioni (ultimi 30 giorni)
I have several excel files (.xlsx) with time data how can i check that the time step is th same in all files and that it does not lack ?

Risposta accettata

Aquatris il 24 Nov 2019
After you load the file in to matlab workspace, name the variable for time. Then you can use diff() function to find the difference in consecutive values.
Assume your time variable is t, then if you do
then, the plot will show you the time steps.
  2 Commenti
Can you show me an example please? When i try the fonction load it does not work. I don't know why.
Aquatris il 24 Nov 2019
Modificato: Aquatris il 25 Nov 2019
I reccommend you use the "Import Data" functionality. From there you can load your data as column vector. Then you can generate a script that does it automatically for you so that as long as your excel sheets are in the same format, you can reuse the loading script for different files by simply changing the name of the file in the script.
You can also open the "Import Data" functionality if you drag and drop the excel file into the Command Window which is equaivalent to using the below command
% excel file to be used C:\Users\PC1\Desktop\New Microsoft Excel Worksheet.xlsx
uiopen('C:\Users\PC1\Desktop\New Microsoft Excel Worksheet.xlsx',1)
Here is an example script that "Import File" generates for a worksheet that has column A with "time" values and column B for "data".
%% Import data from spreadsheet
% Script for importing data from the following spreadsheet:
% Workbook: C:\Users\PC1\Desktop\New Microsoft Excel Worksheet.xlsx
% Worksheet: Sheet1
% Auto-generated by MATLAB on 24-Nov-2019 05:04:36
%% Setup the Import Options
opts = spreadsheetImportOptions("NumVariables", 2);
% Specify sheet and range
opts.Sheet = "Sheet1";
opts.DataRange = "A2:B35";
% Specify column names and types
opts.VariableNames = ["time", "data"];
opts.VariableTypes = ["double", "double"];
% Import the data
tbl = readtable("C:\Users\PC1\Desktop\New Microsoft Excel Worksheet.xlsx", opts, "UseExcel", false);
%% Convert to output type
time = tbl.time;
data =;
%% Clear temporary variables
clear opts tbl
%to visualize the time step

Accedi per commentare.

Più risposte (0)


Scopri di più su Data Import from MATLAB in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by