Index in position 2 exceeds array bounds.

조회 수: 10 (최근 30일)
Daffa Muhammad Fadhil
Daffa Muhammad Fadhil 2020년 9월 29일
댓글: Ameer Hamza 2020년 9월 29일
clc;clear;close all;warning off;
% Proses membaca data latih dari excel
filename = 'CurahHujan.xlsx';
sheet = 2;
xlRange = 'D8:P19';
Data = xlsread(filename, sheet, xlRange);
data_latih = Data(:,1:12)'; <---
target_latih = Data(:,13)';<---
[m,n] = size(data_latih);
i dont know why that line getting an error. it says "Index in position 2 exceeds array bounds."

채택된 답변

Ameer Hamza
Ameer Hamza 2020년 9월 29일
편집: Ameer Hamza 2020년 9월 29일
For some reason, the value in your excel file are stored as text instead of numeric values. The best solution is to fix the excel file. The following code shows how you can read your current excel file in MATLAB
% Proses membaca data latih dari excel
filename = 'CurahHujan.xlsx';
sheet = 2;
xlRange = 'D8:P19';
Data = table2cell(readtable(filename, 'Sheet', sheet, 'Range', xlRange));
Data = cellfun(@str2double, Data);
data_latih = Data(:,1:12)';
target_latih = Data(:,13)';
[m,n] = size(data_latih);
  댓글 수: 2
Daffa Muhammad Fadhil
Daffa Muhammad Fadhil 2020년 9월 29일
Thank you very much
Ameer Hamza
Ameer Hamza 2020년 9월 29일
I am glad to be of help! :)

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by