Index exceed number of elements when using data from an excel table

조회 수: 1 (최근 30일)
Finneas Phan
Finneas Phan 2020년 10월 20일
댓글: Finneas Phan 2020년 10월 20일
Hi guys, i'm doing an assignment on using data from an excel table in Matlab. Our task was to input the given data in form of a table. But when i ran the code, this error pops up and i don't really know where it went wrong or how to fix it. Please help!!
Error - Index exceeds the number of array elements (1).
Error in zadanie25 (line 12)
fprintf(' %12s ',t{i})
clc
Name_F='Таблица Турбобуры.xlsx';
Name_L1='Лист1';
[n,t]=xlsread(Name_F,Name_L1,'g1:g17')
[n,p]=xlsread(Name_F,Name_L1,'j1:j17')
k=xlsread(Name_F,Name_L1,'g1:g17')
for i=1:7000
fprintf(' %12s ',t{i})
fprintf(' %15s \n ',p{i})
fprintf(' %3.1i ',k(i))
fprintf(' %16i ',n(i))
end
  댓글 수: 2
KSSV
KSSV 2020년 10월 20일
Check size of t....it might be less than you expected.
Finneas Phan
Finneas Phan 2020년 10월 20일
I did.. i tried changing the formatSpec from %12 to lower values but the same error still appeared

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

채택된 답변

KSSV
KSSV 2020년 10월 20일
for i=1:length(t)
fprintf(' %12s ',t{i})
end
for i=1:length(p)
fprintf(' %15s \n ',p{i})
end
  댓글 수: 3
KSSV
KSSV 2020년 10월 20일
Infact staright away you can use....
disp(t)
celldisp(t)
t
Finneas Phan
Finneas Phan 2020년 10월 20일
Would it work if it were multiple cells?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by