Importing a two column array from excel

I'm trying to import an excel file, read data from the file into my code. I've tried the import data tool and it opend the data in a new tab. I don't know how to tell my program to read the program from that new tab that is call Variables-chirpdata. When I run the program, it also deletes all the data in the Variables-Chirpdata tab.
I've also tried all of these ways
T = readtable(chirp_data.xlsx)
numData = xlsread('chirp_data.xlsx')
switchpos = numData(:;2);
to call it directly from the file i keep getting error messages of "Unable to resolve the name chirp_data.xlsx." or "Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters."

Answers (1)

Rik
Rik on 2 Oct 2020
You forgot to put the quotes in your first call. That makes Matlab treat it like a variable, not a char array.

3 Comments

Great!! thank you so much! how do I then create a variabe to read all the rows and the second column of that table that it reads?
If you don't actually want a table I would suggest checking if one of the three outputs of xlsread do what you want. Otherwise you can use the normal syntax for tables to manipulate your data. I'm on mobile and I don't work with tables, so I can't easily give you an example.
T = readtable('chirp_data.xlsx');
Wanted = T{:, 2}

Sign in to comment.

Products

Asked:

on 2 Oct 2020

Commented:

on 2 Oct 2020

Community Treasure Hunt

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

Start Hunting!