How to change surf function axis values to not use array index?
5 views (last 30 days)
Show older comments
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.
1 Comment
Accepted Answer
Jan
on 6 Nov 2017
Edited: Jan
on 6 Nov 2017
[X,Y] = meshgrid(-30:0.1:30);
surf(X, Y, Z)
Note: Reading the docs is a good idea.
2 Comments
Jan
on 9 Nov 2017
Edited: Jan
on 9 Nov 2017
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.
More Answers (0)
See Also
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!