Error using mesh - Z must be a matrix, not a scalar or vector, using mesh command
Mostra commenti meno recenti
Dear community,
I am using this code to create a scatter plot in three dimensions using the attached data. However, I encountered the following error: "Error using mesh - Z must be a matrix, not a scalar or vector." It appears to be related to the values of the vector p21. When I multiply it by 100, the code works fine. However, I require the original data. Could anyone assist me with this? Additionally, I would like to make the interpolating plane transparent.
Thank you in advance!
clc; clear;close all;
load ('data')
x1 = p21;
x2 = vp;
y = ucs;
X = [ones(size(x1)) x1 x2 x1.*x2];
b = regress(y,X)
scatter3(x1,x2,y,'filled')
hold on
x1fit = min(x1):100:max(x1);
x2fit = min(x2):10:max(x2);
[X1FIT,X2FIT] = meshgrid(x1fit,x2fit);
YFIT = b(1) + b(2)*X1FIT + b(3)*X2FIT + b(4)*X1FIT.*X2FIT;
mesh(X1FIT,X2FIT,YFIT)
xlabel('P21 [m/m2]')
ylabel('Vp [m/s]')
zlabel('UCS [MPa]')
view(50,10)
hold off
[~,~,~,~,stats] = regress(y,X)
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Creating and Concatenating Matrices in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
