'Array indices should be positive' error

14 Ansichten (letzte 30 Tage)
Vinisha Venugopal
Vinisha Venugopal am 12 Mär. 2019
Kommentiert: Star Strider am 17 Feb. 2020
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.

Akzeptierte Antwort

Star Strider
Star Strider am 12 Mär. 2019
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 Kommentare
Timmy Watt
Timmy Watt am 17 Feb. 2020
This solved my problem too, thank you!
Star Strider
Star Strider am 17 Feb. 2020
My pleasure!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Data Import from MATLAB finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by