Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

plotting 3d graph in matlab

1 Ansicht (letzte 30 Tage)
sumeet
sumeet am 30 Sep. 2017
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
hi,
I want to plot a function on z axis x and y can vary from 0 to 1 .
Two constants c_one and c_two are fed by user.
f(z)=(c_one*x + c_two *y)/(x+y)
So I tried
[X,Y] = meshgrid(0.1:0.1:1,0.1:0.1:1);
Z = ((0.9*X) + (0.1*Y))/(X+Y);
Here i took c_one=0.9 , c_two=0.1
It should simply evaluate z for 100 pairs of (x,y).
I get the message
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 5.473412e-19.
Why does that happen ?
Also , can you suggest a better way to graphically show 100 values (I did surf(X,Y,Z)) ?
Thanks.

Antworten (1)

Star Strider
Star Strider am 30 Sep. 2017
Use element-wise operations:
c_one=0.9;
c_two=0.1;
f = @(x,y) (c_one.*x + c_two.*y)./(x+y)
[X,Y] = meshgrid(0.1:0.1:1,0.1:0.1:1);
Z = f(X,Y);
figure(1)
surf(X,Y,Z)
grid on
See the documentation on Array vs. Matrix Operations (link) for details.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by