Problem with importdata('-pastespecial') on 2014b for GUI
Show older comments
I recently upgraded my version of matlab to 2014b and one of the sections in my code no longer works. The code uses user input from a GUI to create a data table of user defined size filled with zeros. This part executes correctly and displays a table of the correct size populated with zeros.
I then have a push button that when pressed executes the following code to populate the table with numerical data from the clipboard (copied from excel):
if true
function PastePreviousGenerationData_Callback(hObject, eventdata, handles)
% hObject handle to PastePreviousGenerationData (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
import = importdata('-pastespecial');%stores data copied to clipboard
set (handles.PreviousGenerationTable, 'Data', import);%populates old vectors table with copied data
guidata(hObject, handles);
end
In my old version of matlab, this code worked correctly. I could copy m x n cells from excel and they would individually populate the cells of the data table in the GUI. Now, I think the issue is that it doesn't recognize the columns in the excel data anymore?
I've tried fixing it by changing the first line of relevant code from importdata to uiimport. This results in the same issue, but it shows me what I have on the clipboard which looks like its formatted correctly. However, it only recognizes the last cell or two cells when I have more than one column. I've tried entering different sized matrices:
3x9 = Only recognizes and stores the bottom rightmost 2 cells as data
2x9 = Only recognizes and stores the bottom rightmost cell as data
1x9 = Doesn't give me an error anymore, but populates only the first cell of the table with all of the numbers that should be spaced in cells individually.
In the interface that comes up when I run this with uiimport, this happens when I have tab selected, and there is no data when any of the other delimiting options are selected (comma, space, semicolon).
I'm wondering if there is code I can add that tells matlab what I'm giving it and still be able to copy and paste without having to store or save my excel files as .txt or .csv.
For reference, I'm running Matlab 2014b on a Mac with OSx 10.10.1 (Yosemite), and Excel 2011. I noticed the error after upgrading Matlab and upgrading to Yosemite at the same time.
Thanks!
Answers (0)
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!