MATLAB Answers

Import Data - Generate Script/Function Error

21 views (last 30 days)
Joaquin Pinto
Joaquin Pinto on 5 Nov 2019
Commented: Azhar iqbal on 1 Jan 2020 at 16:39
I'm in the process of creating a new model but have been having issues with the "Generate Script" and "Generate Function" options from Import Data (See picture).
The data is saved in an excel file that gets edited occasionally.
I've gotten the same error with all the Output Types, and it only works when I select the importing button directly (not as a script or function, which I need in order to use the model)
I noticed the issue with my attached file, however I've also tried fillling out the empty cells and other excel files, as well as using a different computer (which was also running v 2019b), and no luck as of yet.
The error I am receiving is:
--------------------------------------
Import operation failed. The most likely reason is that there are unimportable cells in the selection.
Try adding a rule in the toolstrip to convert unimportable cells into numbers.
-------------------------------------
As you can see in the picture labeled ImportDataError.PNG, I already have a rule for dealing with the unimportable cells (I've also tried with blank cells and both).
I understand that there are other ways to import the data but I was told by a coworker that they do it this way and prefer me to do it the same way, for consistency.
Is anyone else having this issue/has anyone found a solution?
Thank you for your help!

  1 Comment

Sign in to comment.

Answers (1)

Subhadeep Koley
Subhadeep Koley on 8 Nov 2019
Edited: Subhadeep Koley on 8 Nov 2019
Hi, it is giving no such errors when I am trying to do the same with your Com_SampleProjects.xlsx file. Can I know which MATLAB version you are using?
However, generated the script and the function in my end (see the attached), which you can use.
Hope this helps!

  5 Comments

Show 2 older comments
Joaquin Pinto
Joaquin Pinto on 11 Nov 2019
Hi Subhadeep,
Thank you for your quick responses.
My apologies, I'm realizing that I mispoke.
My working folder is C:\matlab\home_directory (don't know why, that's just how they recomended we set it up)
The excel file can be saved anywhere and it doesn't work while my working folder is in C:\matlab. As soon as I move my working folder away from C:\matlab the error no longer happens.
I found the solution to get the tool to work, I'm just wondering if you know why it doesn't work in C:/matlab. It doesn't even allow me to create the function when doing it from there, so adding those lines of code will not change the issue.
Regardless, thank you very much for your help in solving the issue.
Subhadeep Koley
Subhadeep Koley on 11 Nov 2019
Hi Joaquin, it seems that you don't have the write permission in the file path 'C:/matlab', as you stated that "It doesn't even allow me to create the function when doing it from there..."
Joaquin Pinto
Joaquin Pinto on 11 Nov 2019
I don't think that's it, as I can create scripts and functions on C:/matlab without problem, it's only when I try to import with the tool that it doesn't work and gives me the "Import Operation Failed" error.
By "It doesn't even allow me to create the function when doing it from there..." I meant that I can't even get to the stage where I could add those lines to the script, as I can't even create the script due to the error.

Sign in to comment.

Sign in to answer this question.

Products


Release

R2019b