1 view (last 30 days)

I'm really stuck with this task I've been given. When I run this script of mine written to answer the formula's shown, on line 23 it tells me index exceeds number of array elements. Which it does using h(i+1)-hi(i) , with both of those having 9 numbers in it there will be 8 differences. I'm asked to use formula 4 to get the Pi numbers you see in the table. I get the first 8 values correct, but can't seem to get the 9th number in the formula because index exceeds number of array elements. What I cant figure out is how to get 9 numbers when it has the the diff hi function in there which only has 8 values. I made the Ai column have 9 values by having Ai_1 = [ai, 0], but im not allowed to just insert the final Pi values in. I have attatched a copy of my script in hopes it gives some clarity as well as all the formula's and stuff listed.

To sum it all up I need my Pi values to match up or get very close to the ones listen in table 5, and my pi values (formula shown in files) to get pretty close as well and then print it in a table like 5. Any help is greatly appreciated!!!

Edit: I realise my Fprintf might be incorrect for what Im trying to get at the end.

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

Start Hunting!
## 6 Comments

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/592465-index-exceeds-number-of-array-elements#comment_1006030

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/592465-index-exceeds-number-of-array-elements#comment_1006030

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/592465-index-exceeds-number-of-array-elements#comment_1006033

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/592465-index-exceeds-number-of-array-elements#comment_1006033

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/592465-index-exceeds-number-of-array-elements#comment_1006036

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/592465-index-exceeds-number-of-array-elements#comment_1006036

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/592465-index-exceeds-number-of-array-elements#comment_1006045

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/592465-index-exceeds-number-of-array-elements#comment_1006045

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/592465-index-exceeds-number-of-array-elements#comment_1006219

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/592465-index-exceeds-number-of-array-elements#comment_1006219

## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/592465-index-exceeds-number-of-array-elements#comment_1006387

⋮## Direct link to this comment

https://au.mathworks.com/matlabcentral/answers/592465-index-exceeds-number-of-array-elements#comment_1006387

Sign in to comment.