Help keep getting error: Error using matlab.gra​phics.char​t.primitiv​e.Surface, Value must be a vector or 2D array of numeric type

I keep getting the following error:
Error using matlab.graphics.chart.primitive.Surface
Value must be a vector or 2D array of numeric type
I'm trying to mesh my second order regression results.
Thank you for any help!
figure(7)
scatter3(x1,x2,x3,y,'filled','k');
hold on
x1fit = linspace(min(x1),max(x1),30);
x2fit = linspace(min(x2),max(x2),100);
x3fit = linspace(min(x3),max(x3),100);
[X1FIT,X2FIT,X3FIT] = meshgrid(x1fit,x2fit,x3fit);
YFIT = -2166.2 + 509.5*X1FIT - 1.8*X2FIT + 56.52*X3FIT+3.02*X1FIT.*X3FIT-37.45*(X1FIT.^2)-2.14*(X3FIT.^2);
mesh(X1FIT,X2FIT,X3FIT,YFIT)
xlabel('Substrate')
ylabel('Temp')
zlabel('Yield')
title('Multiple regression surface model')
s = surface;
c = s.CData;
s.CDataMapping = 'direct';
hold off

2 commentaires

The problem is that ‘X!FIT’ and the rest are (30x100x100) 3D arrays.
Unfortunately, in this uinverse (with three large dimensions and time), it is only possible to represent three spatial dimensions and one time dimension. MATLAB follows that convention.
It may be possible to do what you want, however we need more details on what you calculated and what you want to plot.
Hi,
Could you provide more inputs on what you want to achieve. The error is because meshgrid function in the above code is giving 3D arrays as output and these cannot be used as inputs to mesh function.

Connectez-vous pour commenter.

Réponses (0)

Catégories

Question posée :

le 19 Déc 2019

Commenté :

le 31 Mar 2020

Community Treasure Hunt

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

Start Hunting!

Translated by