Script of importing data not working with no warning or error

조회 수: 2 (최근 30일)
YASSER
YASSER 2024년 1월 2일
댓글: Star Strider 2024년 1월 4일
Hello
I am trying to import an excel data by using a ready script,
The problem is when i run it in editor it does not do anything!
and do not uppload the data
Where as when i change the script into a simple commande it works
No warning, no error !

채택된 답변

Star Strider
Star Strider 2024년 1월 2일
The function does not produce any outputs.
You will need to declare:
global ExperimentalIVData
in your calling script to get it to work.
However, I definitely do not suggest using global variables.
Change the script to return ‘ExperimentalIVData’ as an output instead, so the initial function declaration will be:
function ExperimentalIVData = LoadExperimentalIVData
and the problem solves itself. And delete all the global calls.
.
  댓글 수: 6
YASSER
YASSER 2024년 1월 4일
Thank's Sir
Since i am using the imported data in an algorithm & simulink i have to call these variables without tapping anything in command window (variables should appear in workspace just when running the loadExperimentalIVData.mfile ).
Two problems appears:
First: i delete struct comand from the function but still data is in structure in workspace, rather i want each one to be alone.
Second: when i avoid using global variables but data remain local & as consequence it can't be called again (for exemple: simulink can't regognize the variable 'S' & 'T' when calling it from workspace ! )
Star Strider
Star Strider 2024년 1월 4일
As always, my pleasure!
I did not initially know that you wanted to import your spreadsheet data into Simulink.
Reviewing the R2020a documentation (that fortunately still exists), I was able to find the From Spreadsheet block that may be what you need to import your Excel data. I am otherwise not certain how to import your data into Simulink.
I have Simulink, however I rarely use it now, although I have used it extensively, most recently a couple decades ago. I have never needed to import spreadsheet data into it.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Dyuman Joshi
Dyuman Joshi 2024년 1월 2일
편집: Dyuman Joshi 2024년 1월 3일
"The problem is when i run it in editor it does not do anything!"
Because there is no output defined for the function.
There are differences to how scripts and functions work - Scripts vs. Functions
You do not need to use global here. Remove that line and modify the function to provide the variable ExperimentalIVData as the output from the function.
And use readtable/readmatrix instead of the deprecated xlsread().

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by