Filter löschen
Filter löschen

Plotting 4dimentional data error

1 Ansicht (letzte 30 Tage)
james
james am 14 Mär. 2012
Hi all I'm trying to plot the data to see the global minimum point. I'm presented with the equation
C = (1.10471.*((Z).^2)*((X).^2))+(0.0481*(Y*Z)*14*X);
my first issue is that when I try to produce a plot of this I get the error
??? Error using ==> mtimes Inputs must be 2-D, or at least one input must be scalar.
Error in ==> Untitled4 at 5 C = (1.10471.*((Z).^2)*((X).^2))+(0.0481*(Y*Z)*14*X);
My code is x = -10:1:10; y = -10:1:10; z = -10:1:10; [X,Y,Z] = meshgrid(x,y,z); C = (1.10471.*((Z).^2)*((X).^2))+(0.0481*(Y*Z)*14*X); surf(X,Y,Z,C); hold on; axis([-10 10 -10 10 10 10]);
Many thanks

Akzeptierte Antwort

james
james am 14 Mär. 2012
I changed my code to allow for this and still get the mistake!
x = -9:1:10;
y = -9:1:10;
z = -9:1:10;
[X,Y,Z] = meshgrid(x,y,z);
C = (1.10471.*((Z).^2)*((X).^2))+(0.0481*(Y.*Z)*14*X);
surf(X,Y,Z,C);
hold on;
axis([-10 10 -10 10 10 10]);
  1 Kommentar
Walter Roberson
Walter Roberson am 14 Mär. 2012
C = (1.10471.*((Z).^2) .* ((X).^2))+(0.0481*(Y.*Z)*14*X);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Sean de Wolski
Sean de Wolski am 14 Mär. 2012
))+(0.0481*(Y*Z)*14*X);
))+(0.0481*(Y.*Z)*14*X);
Note difference:
doc vectorize
to avoid these errors in the future.
  2 Kommentare
james
james am 14 Mär. 2012
Should this be done after every vector?
Sean de Wolski
Sean de Wolski am 14 Mär. 2012
Whenever you get a error using {mtimes, mrdivide, mpower, mldivide}
and you don't want to be doing element-by-element multiplication.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Discrete Data Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by