Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

plotting 3d graph in matlab

1 visualización (últimos 30 días)
sumeet
sumeet el 30 de Sept. de 2017
Cerrada: MATLAB Answer Bot el 20 de Ag. de 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.

Respuestas (1)

Star Strider
Star Strider el 30 de Sept. de 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.

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by