How to change surf function axis values to not use array index?

6 次查看(过去 30 天)
I have generated a square array of results 601x601 in size, that is a function of x and y. x and y are in the range -30:0.1:30
I can plot the results easily using the surf function and make it display as I wish, however the axes both go from 0-600 corresponding to the array indices. I want to change the axes to represent the range of the x and y inputs (-30:30).
I am sure the answer is simple but I just could not work out how to do it, any help would be greatly appreciated.

采纳的回答

Jan
Jan 2017-11-6
编辑:Jan 2017-11-6
As explained in the documentation doc surf :
[X,Y] = meshgrid(-30:0.1:30);
surf(X, Y, Z)
Note: Reading the docs is a good idea.
  2 个评论
Stephen Laws
Stephen Laws 2017-11-6
Hi Jan,
As expected the answer was incredibly simple as you suggested. Thank you for your help, apologies for the dumb question.
Jan
Jan 2017-11-9
编辑:Jan 2017-11-9
No need for apologies: This is a Matlab forum and questions about Matlab are not only welcome, but needed :-)
After participating in Matlab forums for some years, I know that many users forget to read the docs, because they have learned from many other software, that the documentation is nearly useless: You can understand it only, if you know already how to solve the problem. But the help texts of Matlab are really useful.
I struggle with a port-forwarding by SSH for some weeks now: I have a remote computer, a local computer visible from the internet and a computer visible in the local network only. I've read so many instructions and tutorials, which explain the solution in detail using the terms "computer A, B, C", but without explaining, which one is A, B and C, or even with the expression "on the computer" without mentioning, which one it is. I hate "or apply the equivalent changes in the config file". The solution must be trivial. I assume it is only 6 lines in the 3 config files. But I did not find one working complete example in the net, but many tutorials with many pages, which leave the one or other important detail in the mystic dark. Frustrating.
Therefore I'm really happy about working with Matlab and posting easy solutions for problem, which get trivial - as soon as the solution is known.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by