I'm getting an error which I don't understand: index exceeds matrix dimensions, what does it mean?

1 view (last 30 days)
When i'm using this code: for i=1:size(m,1) VaR(i,1)=-quantile(AEurostoxAR(i+m,1),0.05); end
i'm getting this error: ??? Index exceeds matrix dimensions.
Does somebody know what the error means or what I am doing wrong in my code? I want to calculate the VaR with the historical simulation method. The AEurostoxAR are returns from the EuroStoxx 50 with 782 returns and i'm using a rolling window of 250, so my m=250
Thanks in advance,
kind regards Michiel
  11 Comments
Stephen23
Stephen23 on 11 May 2020
Edited: Stephen23 on 11 May 2020
"when i run the same code for red channel it works but when i try to split green or blue it dosen't work?"
Nope, it does not "work" on the red channel (it actually "works" on a grayscale image).
"The below code is to split red channel"
No, it does not. Your code uses this line immediately after importing the image data:
a = rgb2gray(a);
to convert a (presumably) RGB image to an MxN grayscale matrix. After that line:
  • a does not have a red channel.
  • a does not have a green channel.
  • a does not have a blue channel.
In the rest of your code a is a grayscale MxN matrix. An MxN matrix a does not have red, green or blue channels. It has no color infomation whatsoever, and certainly has no different color channels.
If you expect different color channels, why are you converting to grayscale?

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!