How to generate a coordinate field, compute values for each coordinate and plot the results?
1 view (last 30 days)
Show older comments
Christopher Brokmann
on 30 Jan 2019
Commented: Christopher Brokmann
on 30 Jan 2019
Hello,
first, i would like to generate a 2D coordinate field from e.g. 0/0 to 0/100, 100/100 and 100/0 with 10 steps, giving 11x11 = 121 coordinates.
My first try is:
for i = 0:10
A(:,1+2*i) = 0:10:100;
A(:,2+2*i) = (i)*10;
end
I don't like this solution, especially if I want to calculate larger fields.....
second, i would like to calculate a value for each coordinate, e.g. value = f(x,y). How can i plot the calculated values with its x,y coordinates in a 3D plot?
I would be very grateful for assistance and possible solutions!
Christopher
0 Comments
Accepted Answer
KSSV
on 30 Jan 2019
Edited: KSSV
on 30 Jan 2019
Read about linspace and meshgrid
x = linspace(0,100,11) ;
y = linspace(0,100,11) ;
[X,Y] = meshgrid(x,y) ;
Z = X+Y ;
surf(X,Y,Z)
5 Comments
KSSV
on 30 Jan 2019
Thats striaght forward.....I have given examples above......as you are using matrices ..read about element by element operations in matrices. https://in.mathworks.com/help/fixedpoint/ref/times.html
More Answers (0)
See Also
Categories
Find more on Surface and Mesh Plots 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!