'Array indices should be positive' error

조회 수: 14 (최근 30일)
Vinisha Venugopal
Vinisha Venugopal 2019년 3월 12일
댓글: Star Strider 2020년 2월 17일
Let's say I'm taking an array of values from an Excel file,
maybe the first column in the excel file and I wanna find the standard deviation for it.
So the code is gonna be
col=a(:,1);
std=std(col);
It gives an output for the first run, but when I run it second time, it gives an error saying,"Array indices should be positive". Why?
Kindly help.
Thanks,
Vinisha.

채택된 답변

Star Strider
Star Strider 2019년 3월 12일
This is the reason:
std=std(col);
You ‘overshadowed’ the std function by naming your variable ‘std’.
Do this and the problem will go away:
StDev = std(col);
You will have to change that variable in the rest of your code, however the MATLAB Editor should make that easy.
  댓글 수: 4
Timmy Watt
Timmy Watt 2020년 2월 17일
This solved my problem too, thank you!
Star Strider
Star Strider 2020년 2월 17일
My pleasure!

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

추가 답변 (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