Is it possible to put array index as zero in matlab?

15 ビュー (過去 30 日間)
Ashutosh
Ashutosh 2013 年 9 月 25 日
コメント済み: Grady Fort 2021 年 2 月 26 日
I have boundary value problem in heat transfer. My boundary point starts from 1. However due to the finite difference approximation of derivatives when applying equations at the boundaries the finite difference equation will encounter one point outside the boundary i.e. point zero. I specified the value of the point, however matlab shows error that matrix index should be positive and logical. Does that mean in matlab array index cannot start from zero? If yes, is there a workaround for this, so that I can avoid redefining by boundary points as 1 and restructuring my total program?

採用された回答

ES
ES 2013 年 9 月 25 日
No.. Matlab Array indices start from 1. Very different from all other languages(few) I have worked with.
  4 件のコメント
Ashutosh
Ashutosh 2013 年 9 月 25 日
Okay.. I will try it out... Thank you..
Grady Fort
Grady Fort 2021 年 2 月 26 日
The link:
Has been taken down (Go figure, it was posted in 2013). Could somebody please post the workaround in Matlab code to index an array starting from 0?

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

その他の回答 (1 件)

Vishal Rane
Vishal Rane 2013 年 9 月 25 日
Indexing does indeed start from 1, but you can modify the indexing in your logic to map the required 0th index to the actual 1st index in the matrix/array
  1 件のコメント
hardik pandya
hardik pandya 2020 年 8 月 7 日
Hello sir, could you please explain in matlab code how to do it.

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by