# Doug's MATLAB Video Tutorials

## Video series: Reading Excel data into MATLAB with a GUI

I had a chance to work with a MATLAB user that was interested in bringing her Excel data into MATLAB and plotting different variables. This was a fairly standard file format, just columns of data. It was pretty easy to read in the data with XLSREAD:
Note that three minutes into the video above, I use a neat cell mode trick that many might not know about. Once this was done, it was time to turn that script into a function so that it could be reused easily.
Finally, the function needed a GUI to make it easy to view any piece of data from the file.
The original data file, and all the files created during the movies are located with the movie files. (Data file posted with her permission) Read the Excel data Refactor to script into a function Build the GUI

### 86 Responses to “Video series: Reading Excel data into MATLAB with a GUI”

1. Marcelo replied on :

Excellent videos. I never made any GUI, so this lesson is going to be a start.

2. Gerd Kunert replied on :

Hello,

the “Build a GUI” video is quite helpful.
For further videos, I propose to use a larger Matlab window (in particular width). Then I can see the whole line and do not have to switch to the source code.

Thanks

3. Doug replied on :

Gerd,

I completely agree that it would be nice to see the entire command line. The trade-off I am struggling with is I can only make the screen so wide if I want to embed the video in a web page. I could zoom out, but then the text is illegible.

I will try to use …
short commands or …
the commands can be …
continued like this …
so they all fit on …
screen at once.

If anyone has any other ideas, please let me know. I can make the videos taller and fit in the blog, but 500 pixels wide is all that fits nicely here (that is still 180 more across than I could get on YouTube)

Thanks,
Doug

4. Mike replied on :

Excellent Videos! This way form to learn MatLab it’s simply awesome. Great job!

5. Mauricio Argote-Cortes replied on :

Great videos Doug!

I got a problem when reproducing the Excel-plotting GUI… I guess I am missing something so the outcoming GUI stands by itself fine.

Here is what it happened:

While I was running the GUI from GUIDE or its M-file, everything was ok. When I opened MATLAB again (during a new session) and clicked the .FIG file on the Current Directory Window, the GUI appeared, but it started to produce the following errors:

—————–
handles =

fileName: ’070924bgzFake.xls’

??? Reference to non-existent field ‘popupmenuX’.

Error in ==> PlotExcelGUI>pushbuttonLoadXLS_Callback at 140

Error in ==> gui_mainfcn at 95
feval(varargin{:});

Error in ==> PlotExcelGUI at 42
gui_mainfcn(gui_State, varargin{:});

??? Error while evaluating uicontrol Callback

—————–

How can I make the .FIG file to run my GUI without getting into GUIDE each time?

Thanks. And again, great job for those videos!

Mauricio

6. Richard Lim replied on :

I tried downloading the mainGui.fig, mainGui.m and the excel file so I can run it, and the gui came up just fine, but once I selected the excel file, I got some callback errors:

?? Reference to non-existent field ‘popupmenuX’.
Error in ==> mainGui>pushbuttonLoadXLS_Callback at 130
Error in ==> gui_mainfcn at 75
feval(varargin{:});
Error in ==> mainGui at 42
gui_mainfcn(gui_State, varargin{:});
??? Error while evaluating uicontrol Callback.

Any ideas?

7. Doug replied on :

Mauricio and Richard,

To run this GUI, you should run the .m file, not the .fig file. The .m file contains a lot of important initialization code that should be run.

Doug

8. Richard Lim replied on :

Hi Doug,

Thanks,
Richard

9. FFA replied on :

Hi

Thanks a lot to you Doug Hull, I have learned a lot about MATLAB specially GUI by your video.

I am from very distance area but I am very interested in MATLAB.

In few words I am a big fan of yours

thanks again

FFA

[minor typos corrected, Doug]

10. Trevor replied on :

Hi
Thank you very much for your videos, I am a final year electrical engineering student and your videos have helped me produce MATLAB code that will be really useful in compleating my final year project.

many thanks
Trevor

11. Maryam replied on :

Hi,
I have a similar question about importing excel data into matlab, but about a more complicated type of file. My excel files has a lot of text near the top, and then many columns of data with x-y-z locations for 3-D points. After ALL of this data, there’s some more text, and then EMG data. I want to write a function to read through past the text, find the columns of data I’m interested in, and store them in their own variables. Do you know how I would go about doing this?

12. Doug replied on :

Maryam,

This is getting into reading custom formats inside of an Excel file. MATLAB gives you the ability to read an arbitrary range inside of an Excel file, and the ability to parse those results. These are the low level functions that are need to accomplish this goal. There is no built-in function that will do what you want since files can vary so much. However, you should be able to build your own.

Doug

13. farasha replied on :

Is this code will face problems if it used in matlab 6.5 ? because that happen to me
I mean the code used to read from excel files ..

Thanks

14. farasha replied on :

I want to know if it is possible to write data into an excel files using GUI Matlab program ??
Right now I am going to develop a big program that takes data from first users and make several kinds of calc as an output … excel file it is suppose to store these results (by Matlab supervision of course)… and for other users it is should to review latest results , makes same calc and then makes it is Owen results in different excel files …..
Is there any advice U can give me here?

15. Doug replied on :

Farasha,

I developed this code in 2007a. I just tried it in MATLAB 6.5, but it seems that XLSREAD was improved since then and this code does not work in 6.5.

For your second question, yes, you can write out Excel files. This functionality has been introduced since 6.5. You will likely want to upgrade to take advantage of these new features.

Doug

16. sivapriya replied on :

Hi,

My question is can i run an m file from excel sheet? i know i can read data from excel sheet and do calculations in matlab and then return the data to the excel sheet but this requires running of the m file. I am in the process of developing a userfriendly software and i feel combination of excel with VB will be more fit for the purpose. Please do reply.

regards
sivapriya

17. Doug replied on :

Sivapriya,

I think you want:

MATLAB Builder EX
http://www.mathworks.com/products/matlabxl/index.html

Doug

18. Jason replied on :

I am trying to plot data in 3D. I have degrees for axis 1 across the top, degrees for axis 2 down the side, and the data (which will be the Z-axis) are what is in the matrix. How do I modify the mainGUI to incorporate x,y, and z and recognize that there isn’t a “heading” for the column 1 since that is actually one of the axis and not the data itself.

Thanks,
Jason

19. Doug replied on :

Jason,

This is quite a bit different from the GUI that I have here. I think you would be best served to start a new one with the knowledge you have gained in making this one.

I am not sure I understand the last part of your question. You might be better served by asking this of tech-support:

http://www.mathworks.com/support

Doug

20. izzri replied on :

Dear Doug,
I would like to merge data files from a few .xls files in one .mat file. Since in .xls file the max no. of column is 256 but I need 600 columns for my input data. That’s why I split data in few .xls files. I know that I can do it by cut and paste the data in .mat file but it will be time consuming. Is there any other way to do it? Please help. Thanks

regards,
Izzri

21. Doug replied on :

Izzri,

You can read in from several files and then concat the variables together:

c = [a b];

Enjoy,
Doug

22. Hamid replied on :

Dear Doug Hull,
Hi!
I have seen your tutorials and I have to admit that I have learned a lot thanks to your efforts.
While watching the tutorials I noticed that there aren’t any which covers the table component to be used as UI in order to collect and save editable data in a file in order to eliminate the dependency of Excel. I have tried to search for a hint but failed to find any which helps. I wonder if you are kind enough to show likes of me a hint on how to save editable data from a table to a file and then load it back to the table.
Respect,
Hamid

23. Doug replied on :

I have not blogged it yet, but I have the video you seek on the file Exchange:

Enjoy,
Doug

24. Matt replied on :

Doug,

I have no trouble reading in files, manipulating the data and plotting. My trouble is I want to do this with quite a few data files.

Is there a way to run through all the files in a folder or directory without inputting the file names manually? Can you help me automate this process?

A.K.A.
1) I want to open a file in a folder
2) Read the data into MATLAB*
3) Manipulate it *
4) Open the next file in the folder and repeat

25. Doug replied on :

Matt,

I think you want this:

http://blogs.mathworks.com/pick/2008/02/26/matlab-basics-getting-a-directory-listing/

Doug

26. Antonio Macanita replied on :

Excellent. Thanks a lot.

27. Jon replied on :

Hi Doug, thanks for your video about reading an Excel file from Matlab. I am pretty new to Matlab but I have been presented with a project to work on that I think Matlab will help with.

I have an Excel sheet with a lot of data that I need to make searchable for specific user-defined values. (I was thinking of putting in some user prompts). It seems like xlsread reads the entire Excel file, or a range of cells in the file. For my purposes I will only need to read one or a few cells at a time. Then I need to load a DLL for a data analysis program I have (I was thinking about using the Matlab Generic DLL Interface), and call specific functions to operate on the data, and then I was thinking about using xlswrite to print the results to a new worksheet or to the next page within the same Excel file.

For example, I run the program and I happen to be interested in Temperatures between 95 and 100. So I search for all of these values that might be in the Excel file, then let’s say I have a function in my DLL file called TEMP2. I would call that function and use it to process these temperatures.

Do you think I am on the right track? Could you possibly help me figure out how I can accomplish this?

Thank you.

28. Scott Hirsch replied on :

Jon -

You definitely seem to be on the right track. I’ve been working with others here in MATLAB land to study the experience of new-ish MATLAB users, so I’d be happy to offer some help (in exchange for you telling us what’s easy and what’s hard for you). Drop me a line – my email is on my MATLAB Central page. (http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectType=author&objectId=919425)

-scott

29. Jon replied on :

Thanks Scott, I will probably send you an email.

Basically what’s hard for me is wading through the syntax when first starting out, it’s not obvious to me what certains commands do unless I can see an example of where it is used.

I am pretty good at adapting examples to my specific problem.

The main concerns I have is that the DLLs I have won’t be compatible with the Matlab DLL Interface and I’ll end up using a Fortran script (which is originally what the data software people recommend, but what do they know about Matlab?)

30. Henry replied on :

Hi Doug,
Following your fantastic tutorial, I try to create a GUI bringing my Excel data and doing some calculations. My excel file has 20 worksheets(20 subjects), and each worksheet has data. These are part of my code:

fileName = handles.fileName;
[tpe, xlSheets] = xlsfinfo(fileName);
set(hObject, ‘string’, xlSheets);

It updates all sheet names on popup menu. Then I want it automatically updates data when I select different name from popup menu. So my question is how to get data from each sheet? I tried “get(handles.popupmenu1, ‘value’)” but it doesn’t work.
Any help will be highly appreciated! Thanks.

31. Doug replied on :

Henry,

It is not clear to me the specific question you need answered. I think you have a pop-up menu that is correctly populated with the various sheet names from your Excel file. From there, you want to figure out the name of the sheet that was selected in the pop-up.

Value will give you an ordinal number. You need to then use this number to index into the cell array that is stored in the ‘string’ property to get the actual string that represents the sheet name.

Doug

32. maram replied on :

hi,
I have a question
I have a matlab code and i want to read a data from SQL server database to use it in that code

so i want to know if i can read this data? if yes, how can I do this ?

Best Regards,
Maram

33. Doug replied on :

Maram,

You might want to look at the Database toolbox.

http://www.mathworks.com/products/database/

Doug

34. MATLAB newbie replied on :

Look this is a great video but for a person totaly new to MATLAB there is a big problem in this tutorial. You need to identify what each code means. you say something like: setPopupmenuString(handles.PopupmenuX, eventdata, handles) what is setPopupmenuString? what are handles? setPopupmenuString (you never explain what is needed in here, what does it mean? Why you need it?)

35. MATLAB newbie replied on :

the first two videos are fairly easy to understand but the last one is abit confusing because I did not know what code to start with. I think you should explain in more detail why you should type this code? what does it does? one after every line. thanks

36. MATLAB newbie replied on :

btw how do you get filename if the file I wanted to get does not have any suffix? Can I do it this way?
–> fileName = uigetfile(‘*’)

37. MATLAB newbie replied on :

Hi Ive tried the same method used for unidentified files witout any suffix and I failed. What modifications to the codes you need to do for an unidentified file to get the same result as this tutorial?

38. dhull replied on :

Hello “MATALB Newbie”

There is always the difficult decision on how much detail I need to discuss in a video. This third video was already 13 minutes, nearly three times the average length. Sometimes, details need to be skipped.

There are plenty of other video that discuss the questions you have, like what is “handles”

You can see all the GUI videos here:

http://blogs.mathworks.com/videos/category/gui-or-guide/

Doug

39. MATLAB newbie replied on :

Hi

My current version of MATLAB is 7.6.0 R2008a can it read Microsoft Excel 2007? i.e. .xlsx instead of .xls. If it is possible, what changes must I make to the xlsread code?

regards

MATLAB newbie

40. dhull replied on :

“Newbie”,

Have you tried this? It worked for me without issue, so I assume yours did not work. What was your code?

Doug

41. MATLAB newbie replied on :

fileName = ’1.xlsx’

fileName =

1.xlsx

??? Undefined function or method ‘xlsxread’ for input arguments of type ‘char’.

42. dhull replied on :

Check the spelling of the command, XLSREAD.

43. MATLAB newbie replied on :

Hi

Do you have a video that teaches you to write a program that automatically creates an excel file and writes data into that excel file once you execute the program?

44. Amine replied on :

Hi Doug,

I have recently built up a GUI which has multiple functionality of downloading Documents from an ftp server, listing dir and opening local files. what I want to do next is include a window on the GUI where I can load an excel sheet on it. i.e. have GUI like a remote desktop for that spreadsheet where I can modify/change/save…ect the data.

I have managed to add Microsoft office spreadsheet 11.0 activeX, but when implementing it within the GUI, it doesn’t ask me for which spreadsheet I want to open instead it loads a blanc one and everytime I export the data to Mic Off excel it saves it automaticaly under a different excel file.

I can open the file with the following matlab commands but I can’t really manage to link it to open within the GUI:

excel = actxserver(‘Excel.Application’);
file = excel.Workbooks.Open(xlfile);

It would be great if anyone can help.

Thanks.

45. dhull replied on :

Amine,

The documentation on how to interact with actX controls is with the maker of the control, so there is not much I can do to help you here. I would check with the maker of the control to look for documentation on it.

Doug

46. dhull replied on :

@”MATLAB Newbie”

xlswrite will do what you are asking for.

a = magic(3)
xlswrite(‘foo.xls’, a)

47. Lucy replied on :

Hi Doug,

I really like the style of your Matlab tutorials!!

A question: in the GUI you created I’d like to be able to select multiple values from the pop-up menu and plot them on the same graph. How can I alter your code to do this??

Many thanks

Lucy

48. dhull replied on :

@Lucy,

Thanks for the kind words. You can only select one value from a pop-up. Change it to a list box and change the MAAX property (weird, I know) so it is multi-select. The rest would be a matter of changing the plotting code to deal with all the selected values.

Doug

49. ros replied on :

Hi,
I am trying to export a ‘figure’ and some Numerical data into excel. I first save’figure’ using ‘activx’ and then I write numerical data using ‘xlswrite’. but everytime matlab overwrites the existing data in excel. Is it not possible to write both figure and data with just matlab commands(without installing any other tools)? Please help.
thanks.

50. dhull replied on :

@ros,

Are you always using the same filename for Excel? That is why it is overwriting maybe. If you are using the same file name, what do you want to happen?

Doug

51. ros replied on :

i want to use same filename. and i want to write one figure and under that some numeric data. If i write figure first using activx and then use xlswrite to write numeric data then figure is gone and only numeric data remains and vice versa.

52. ros replied on :

….and i do not know following things:
1)how to write a fig in excel using xlswrite
2)how to write data in excel using activex commands.

53. Ram replied on :

Hi Doug,
I am trying to open a Excel file which has multiple sheets. I can use winopen command to open any file in MATLAB. But how could open a specific work sheet?

If anyone could answer this, it will be very helpful. I am looking for a quick win.

Thanks!

54. dhull replied on :

@Ram,

Doug

55. Aaron replied on :

If I added a second axes on the GUI, how would I implement the code to plot two different graphs on the same GUI? Both plots are coming from the data that is read into Matlab from excel, just like the tutorial shows. I just want to be able to produce two plots in one GUI.

56. dhull replied on :

@Aaron,

What have you tried. Where is the stumbling point? Adding a second axis, are both plots going to the same axis? You should capture the handles from each axes and use them as inputs into the plotting functions.

Doug

57. Aaron replied on :

It seems the same plot ends up on both axes. I tried to implement a plot axes pushbutton for both axes. This is what I have for code under the plot axes pushbutton.
function PlotAxes1_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to PlotAxes1_pushbutton (see GCBO)
% eventdata reserved – to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fileName = handles.fileName;
axes(handles.axes1)
hold all
plot (handles.axes1, x,y)
axis ([320 400 0.760 0.900])
guidata(hObject, handles)

This plots on both axes. When I try the next function plot axes2 pushbutton it does not seem to plot the data into axes2. The axes1 data plots in both axes1 and axes2

I am not sure if this is the right approach.

58. dhull replied on :

@aaron,

I think I must not understand you. I think you are saying that the above code puts the same plot on two different axis. The above code would not do that though.

Doug

59. joshua replied on :

Hi Doug, thank you for your videos, they really help!

Today I follow your example here, when I copy and paste the callback of push button from inspector, it gives me this:

when I run, it says something wrong with hObject.

then I change the hObject to gcbo, change eventdata to [], it works perfectly.

Would you like to suggest any reason could lead to such a problem?

My matlab version is 2011b.

thank you very much!

60. doug replied on :

@Joshua,

It is not clear to me what you are attempting to do, but I think that you are copying from the property inspector and that was not covered in the video. It is too much to explain in a comment though.

Doug

61. Denky replied on :

Hi Don
I have the same problem as Josua

Today I follow your example here, when I copy and paste the callback of push button from inspector, it gives me this:

when I run, it says something wrong with hObject.

then I change the hObject to gcbo, change eventdata to [], it didn’t work.

What should I do here?

My matlab version is 2012a.

thank you very much!

62. Vaibhav Jain replied on :

Hello Mr.Hull,

I am a newbie to programming and have chosen MATLAB to start with. I want to make MATLAB a better alternative to Excel for my research purposes. Your videos are helping me finding a way through. Thank you for that!

I have to generate graphs from several (thousands) of CSV files generated from simulation runs. These CSV files have yearly-hourly values of different variable such Air temperature, humidity, etc. That means in one file I usually have to deal with 8760 rows (for no. of hours in an year) and many columns. And when the files are in thousands of number, then I have a huge data to process.

I have two questions from you, which are:

1.The first column array of the CSV file is in Date-Time format e.g. “01/01/2012 01:00:00″ and so on. When I import this file into MATLAB it separates this Date-Time column from the rest of the data, and treats it as a text data. So how can I plot a graph between this Date-Time column and the other data columns. Do I have to convert this date-time values into numeric values and then bring it to MATLAB, but then I have to match between year 1900 date-time format of csv and year 0000 date-time format of MATLAB. What is the best way to deal in such situation?

2. How to deal with multiple files since many times I have to plot graph between column arrays from different files?

I would appreciate, if you can give some momentum to my programming learning.

Thank you!
Vaibhav Jain

PS: I can send you a copy of the CSV file, if you wish to look into it. Please let me know how I can send it to you.

63. Doug replied on :

@Vaibhav,

I think you want this:

http://www.mathworks.com/help/releases/R2012a/techdoc/ref/datenum.html

For the second question:

Just read the data in from the multiple files, once it is in MATLAB, it does not matter that it came from separate files.

Doug

64. Glen replied on :

Hi Doug!
For some reason when I’m trying to xlsread a specific range of rows and columns from he exel file, I get the following error:
Warning: Could not start Excel server for import, ‘basic’ mode will be used. Refer to HELP
In exelDTV at 1
Warning: Range cannot be used in ‘basic’ mode. The entire sheet will be loaded.
In exelDTV at 1
Where exelDTV is my assigned variable. I tried looking at row 186 and changing value of ‘Basic = true’ to ‘false’ but it didn’t work,I just get more errors. The help section says that I cannot use range command unless I have a machine running Windows OS with exel installed on it, which I do. Is there any way to fix this issue?

65. Glen replied on :

I also have this problem that a couple of people here seem to have. When I copy the callback from property inspector I get an error that says that ‘Undefined function or variable ‘hObject’.’ For some reason your callback string has ‘gcbo’ instead of my hObject and [] instead of my ‘eventdata’. What could be the reason for this? Matlab version is 7.14.0.739 (r2012a)

66. Doug replied on :

@Glen,

What platform are you on?

As stated in our documentation: The full functionality of XLSREAD depends on the ability to start Excel as a
COM server from MATLAB. If your system does not have this capability (as on a non-Windows platform
such as a Mac or Linux machine), the XLSREAD syntax that passes the ‘basic’ keyword is recommended.
As long as the COM server is available, you can use XLSREAD on Excel files having formats other than
XLS (for example, HTML).

67. Kavita replied on :

Hi!!
I am new to MATLAB and really the Video Tutorials helps a lot in understanding GUI feature of it.
Question:I had followed all the above steps and when I run .m file, figure window opens and I loaded Excel file but when I came to choose the column to plot following error is occurring.Can you please tell me where is the problem..??
Following is shown in command window::
handles =

figure1: 153.0017
axes1: 154.0017
output: 153.0017
fileName: ‘project1 – Copy.xls’

??? Reference to non-existent field ‘filename’.

Error in ==> main>updateAxes at 145
fileName = handles.filename;

Error in ==> gui_mainfcn at 75
feval(varargin{:});

Error in ==> main at 42
gui_mainfcn(gui_State, varargin{:});

??? Error while evaluating uicontrol Callback.

>>
Regards
Kavita

68. Glen replied on :

Hi Doug
Sorry, I was not too specific. The weird problem is that I am using Windows XP 64 bit with Excel installed on it. I asked my system administrator if Excel is running virtually, but this seems to be not the case. What could be the issue? I tried reinsalling excel already. Really need help here!!

69. doug replied on :

@Glen

@Kavita

fileName ~= filename

Check capitalization.

Doug

70. Glen replied on :

Doug,thank you so much for all your help, you are literaly doing god’s work! But I’ve got another issue. I tried compiling that software we created in this tutorial and everything works fine until I upload an excel document-nothing hapens. It’s as if the excel document is not stored in the program. How can I fix this problem? Again,sorry for being so annoying with all those questions!

71. doug replied on :

@Glen,

Is the excel file on the path of the executable?

72. Glen replied on :

Doug,
I am not 100% sure what you mean by that, but here’s what my file selection process looks like:
I have an .xls file in folder ‘A’
I compiled the script and put it in a folder ‘B’
When I launch software,everything seems to work fine, but once press load.xls button, find the file and select to open it, nothing happens. The files I compiled were:
Main file> .m file we created
Additional file> .fig file with the gui layout and my background picture.
I tried doing it on 2 different computers and even created a different function with uigetfile command in it, and the issue is always the same. It seems like uigetfile command is not supported by compiler or some important files are missing. Thanks for your help!!!

73. Glen replied on :

Doug,
Nevermind my last post, I figured out what you meant by your previous answer, everything works well now! Thank you very much for your great tutorials and answers!

74. Ricardo replied on :

Hello Doug!
I am working developing a GUI, i have to take a excel file, and do some plots, OK so far no problem, but I would like to be able to take the excel file from a different folder which is always random, With uigetfile I can only get the file in the same folder that I am. I see that is a similar problem than the @Glen, but he does not say what the solution is.
i will appreciate your help a lot, even if you want I can send you the script.
Thank you very much!!

75. Doug replied on :

UIGETFILE lets you change folders. I do not understand your question I guess.

76. Ricardo replied on :

Yes sorry, i didn’t explain it very well. when I pres the button LoadXLS it opens a window, if i have the excel file in that window the GUI works perfect. But if I have to take the excel file from another folder,I can change the folder, but when i select the file I have this error:

Error in gui_mainfcn (line 96)
feval(varargin{:});

Error in TempEstimationCapacitorGUI (line 42)
gui_mainfcn(gui_State, varargin{:});

Error while evaluating uicontrol Callback>

Is searching the file in the current folder, not in the folder that I want.

Thank you!

77. Ricardo replied on :

Sorry part of the beginning error message was lost :

78. Ricardo replied on :

XLSREAD unable to open file ‘Winter.xlsx’.

79. Doug replied on :

[FileName,PathName,FilterIndex] = uigetfile(FilterSpec)

You can get it from the other outputs of uigetfile. You might need filesep and fullfile to get the full filename.

80. Ricardo replied on :

Ok, Thank you very much! I am going to try it

81. Ad Ke replied on :

Hi, wonderful video. I would like to request a part IV that feature show to turn that wonderful GUI into a stand alone executable. Thanks for doing these.

82. Anand M S replied on :

Sir,I am unable to dump the contents of excel sheet into the uitable created in GUI.*I am using data from excel sheetes to write matlab programs. Also I have crating a GUI containing all the program codes. But i want to display the data in a uitable from the excel sheets and I am unable to do it. I have wriiten the following code

f = figure(‘Position’, [200 200 400 150]);
dat= rand([10,3]);
cnames = {‘Actual’, ‘Forecast’, ‘Error’ };
rnames={’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9′,’10′}
t = uitable(‘Parent’,f,’Data’,dat,’ColumnName’,cnames,’RowName’,rnames,’Position’,[20 20 360 100]);

From the above code table is created in a new figure with specified rows and columns. But the entries contains some redundant data and i havent provided any path to excel. I don’t want to use ‘rand’command which grenerates redundat data while I want to store excel sheet contents in uitable.How can I do this?

83. Doug replied on :

@Anand,

Doug

84. Shashank Singh replied on :

Hello Doug,

Thanx.

Shashank

85. Nikhil replied on :

Hello Doug,

In the 3rd video you have explained how the data in the excel file can be used through out the GUI using the sytax guidata(hObject, handles). What do we need to do if we have two excel files? or some other thing which even should be available through out the gui?
Is this possible? If so how can this be implemented. Looking forward for the answer.

86. Doug replied on :

 Name (required) E-mail (required, will not be published) Website (optional) Spam protection (required): What is 3 + 9 ?

Wrap code fragments inside <pre> tags, like this:

<pre class="code">
a = magic(3);
sum(a)
</pre>


If you have a "<" character in your code, either follow it with a space or replace it with "&lt;" (including the semicolon).

Doug Hull is a proud MathWorker who is on a mission to help you with MATLAB.

These postings are the author's and don't necessarily represent the opinions of MathWorks.