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

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일

0 개 추천

No.. Matlab Array indices start from 1. Very different from all other languages(few) I have worked with.

댓글 수: 4

That means, there is no other alternative than to restructure my entire code?
ES
ES 2013년 9월 25일
편집: ES 2013년 9월 25일
check this out. This would suffice. But it is a lot of workaround i would say.
Okay.. I will try it out... Thank you..
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일

0 개 추천

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

Hello sir, could you please explain in matlab code how to do it.

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

카테고리

도움말 센터File Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품

태그

질문:

2013년 9월 25일

댓글:

2021년 2월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by