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 日

1 投票

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 件のコメント

Vinisha Venugopal
Vinisha Venugopal 2019 年 3 月 12 日
It worked. Thank you :)
Star Strider
Star Strider 2019 年 3 月 12 日
As always, my pleasure!
Timmy Watt
Timmy Watt 2020 年 2 月 17 日
This solved my problem too, thank you!
Star Strider
Star Strider 2020 年 2 月 17 日
My pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Startup and Shutdown についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by