Requirements for load() argument

조회 수: 1 (최근 30일)
Konstantin Shchukin
Konstantin Shchukin 2022년 11월 4일
댓글: Walter Roberson 2022년 11월 5일
Dear all,
in a moment I'm trying to get in touch MATLAB App Designer. To load the datafile I want to use next steps:
[data,path] = uigetfile({'*.dat';'*.txt';'*.*'});
fullpath= strcat(path,data);
spectrum0 = load('fullpath')
But unfortunately the load() function with the name of full path to the file doesn't work. After inserting the original path to the file all the rest works perfectly. My suggestion of problem is that variety type of 'fullpath' is not suitable for load() function. Could you recommend me any solution? Thank you in advance!
Best,
Konstantin

채택된 답변

Chris
Chris 2022년 11월 5일
편집: Chris 2022년 11월 5일
The variable fullpath is a string already. When you use 'fullpath' in quotes, that's passing the string "fullpath" to load. Remove the quotes to pass the variable to a function. But load() expects a .mat file, or "an ASCII file containing numeric data with same number of columns in each row." If your file is formatted like that, fantastic. Otherwise, you might need something else.
readmatrix() or importdata() will load, e.g., a csv file.
If it's pure text, readlines() might work.
  댓글 수: 1
Walter Roberson
Walter Roberson 2022년 11월 5일
When you use unusual extensions, load() cannot always guess whether the file is binary or text. You sometimes have to use the -ascii option to give it a hint.

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

추가 답변 (0개)

카테고리

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

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by