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

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 Comments

Check size of t....it might be less than you expected.
I did.. i tried changing the formatSpec from %12 to lower values but the same error still appeared

Sign in to comment.

 Accepted Answer

for i=1:length(t)
fprintf(' %12s ',t{i})
end
for i=1:length(p)
fprintf(' %15s \n ',p{i})
end

More Answers (0)

Asked:

on 20 Oct 2020

Commented:

on 20 Oct 2020

Community Treasure Hunt

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

Start Hunting!