I was following the protocol on page 1-13 of this pdf (https://www.mathworks.com/help/pdf_doc/matlab/import_export.pdf) and I keep getting the error "Expected one output from a curly brace or dot indexing expression but there were 9 results". What is wrong? Here is my code:
numFiles = 9;
range = 'A1:B7883';
sheet = 1
myData = cell(1,numFiles);
fileNum = 0:45:360
for i = fileNum
fileName = sprinf('%ddeg_y_polarized.0.dpt',i)
myData{fileNum} = importfile(fileName,sheet,range)
end

댓글 수: 2

Magdy Saleh
Magdy Saleh 2018년 7월 5일
Hi, can you please show me what your importfile function looks like?
Thanks
Melissa Klara Kovar
Melissa Klara Kovar 2018년 7월 5일
I used saved it from the instructions in the doc

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

 채택된 답변

OCDER
OCDER 2018년 7월 5일
편집: OCDER 2018년 7월 11일

0 개 추천

% for i = fileNum <<<< this is wrong. you get a vector of 0:45:360
for i = 1:length(filenum)
fileName = sprintf('%ddeg_y_polarized.0.dpt',filenum(i))
myData{i} = importfile(fileName,sheet,range)
end

댓글 수: 4

I am still getting the error message "Expected one output from a curly brace or dot indexing expression but there were 9 results". Here is my updated code
numFiles = 9;
range = 'A1:B7883';
sheet = 1
myData = cell(1,numFiles);
fileNum = 0:45:360
for i = 1:length(fileNum)
fileName = sprintf('%ddeg_y_polarized.0.dpt',fileNum(i))
myData{fileNum} = importfile(fileName,sheet,range)
end
OCDER
OCDER 2018년 7월 11일
See the corrected code in the answer above.
Melissa Klara Kovar
Melissa Klara Kovar 2018년 7월 12일
Yes it worked! Thank you!!!
OCDER
OCDER 2018년 7월 12일
You're welcome! When you get the chance, "Accept" answers that work for you - it'll let others know this issue is resolved and also reward volunteers who helped out :)

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

질문:

2018년 7월 5일

댓글:

2018년 7월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by