How can I create a MATLAB function for importing data from an Excel table?

In summary, the conversation is about creating a function in MATLAB for a table in Excel. The table has a header (34x1 array) with characteristics such as rise time and fall time, and data for waveforms (34x88 array). The bottom part of the table is made up of a 10001x88 array and does not have any blank cells between it and the top part. The goal is to write MATLAB codes to easily access the data instead of using Excel. One suggestion is to let MATLAB read the data from Excel, but the person needs to follow the specific format described.
  • #1
Tina22
5
0
Hi all,

I am trying to create a function in MATLAB for a table in Excel. Basically, I have to define a header (an array 34*1), waveform characteristics (that is an array 34*88), and finally data for the waveforms (that is a array 10001*88). Could you please help me on that??

Thanks
 
Physics news on Phys.org
  • #2
You really need to give more details. Questions:

1)

What do you want in the header (34x1 array)?

a 34x1 array of characters will only hold 34 characters, so if you have 34 features to describe wave characteristics, you'll only be able to use one letter for each feature.

2)

I'm assuming these are meant to be two different tables (one with a text header above each column). Do they go on the same, separated by blank cells, or do they go on another sheet? Or am I totally misunderstanding your goal here?
 
  • #3
You are right. I would have explained more. Sorry about that.

1) I would like to have some characteristics in the header like rise time, fall time,etc. Isn't it possible?

2) Basically, There are not two different tables. Let me explain more. Header is not above each column, it is the first vertical column in the table, that's why I define the array like 34*1.

There should not be anything above each column. I have the data right in front of the header and that's all for the top part of the table.

For the bottom part (waveforms data), it starts exactly after the top part finishes (no blank cell between). That's why the array (10001*88) for that has the same columns like the waveform char data (34*88).

I am trying to write MATLAB codes for that (basically a function) to easily access the data, instead of using Excel.

Your help is greatly appreciated.
 
  • #4
why don't you use excel and let MATLAB read it?
 
  • #5
because I have to do it in the way I explained above.
 

1. What is a function in MATLAB?

A function in MATLAB is a group of commands or statements that perform a specific task. It is a reusable piece of code that can take inputs and produce outputs. Functions help in organizing and simplifying complex programs.

2. How do I create a function in MATLAB?

To create a function in MATLAB, you can use the "function" keyword followed by the function name and its input arguments. Then, write the code for the function, including the desired output. Make sure to save the function in a separate .m file with the same name as the function.

3. What are the input and output arguments in a MATLAB function?

Input arguments in a MATLAB function are the variables that are passed to the function when it is called. These variables are used as inputs for the code inside the function. Output arguments are the variables that are returned by the function after it has completed its task.

4. Can I use a function within another function in MATLAB?

Yes, you can use a function within another function in MATLAB. This is known as nested functions. A nested function has access to all the variables in the parent function and can also modify them. However, it is good practice to avoid using nested functions as they can make the code more complex and difficult to debug.

5. How do I call a function in MATLAB?

To call a function in MATLAB, you need to use its name followed by parentheses. Inside the parentheses, you can pass the required input arguments. If the function has output arguments, you can assign them to variables when calling the function. The function will then execute and return the desired output.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
405
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
2K
Back
Top