Problem with mesh function: ??? Index exceeds matrix dimensions.

Hello,
I have the above named error all the time, but I can't see the dimension problem.
-------------------------------
figure
x=[1:31];
y=[1:5];
[X,Y]=meshgrid(x,y);
Z=Price(x,y);
mesh(X,Y,Z)
xlabel('Stock Price')
ylabel('Sigma')
zlabel('Call Price')
-------------------------------
"Price" is a 31x5 matrice. I tried also playing with m x n changes of all inputs but nothing did work so far.
Thank you a lot for your help.
Dominik

 採用された回答

Walter Roberson
Walter Roberson 2013 年 4 月 6 日

0 投票

If you are getting "index exceeds matrix dimensions" on the mesh() call, then likely you have accidentally created a variable named "mesh".
Note: if x and y are those vectors then Price(x,y) would be the same as Price by itself, and there would be no reason to use meshgrid(). Just mesh(Price);

3 件のコメント

Dominik
Dominik 2013 年 4 月 6 日
No, there is no variable called "mesh".
I will consider your note, but the meshgrid solution I chose isn't the problem?
Dominik
Dominik 2013 年 4 月 6 日
ok, I solved it: I fliped x and y in meshgrid(x,y);
Walter Roberson
Walter Roberson 2013 年 4 月 6 日
I do not get "Index exceeds matrix dimension": I get "data dimensions must match".
Change your meshgrid() to ndgrid()

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by