Error using scatteredInterpolant The input points must be specified in column-vector format.
15 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
This is my code .I am trying to plot a multivariate equation containing 3 independent variable and 1 dependent variable.Getting this error.
X1= double(data.time);% Assuming time, temperature, humidity are columns 3, 4, and 5
X2=double(data.temperature);
X3=double(data.humidity);
Y = double(data.soil_moisture); % Assuming soil moisture is in column 6 -it is the dependent variable
% Define your multivariable equation as an anonymous function
f = @(X1, X2, X3) 5.5899 -0.0142 * X1 -0.0741 * X2 -0.0347 * X3;
% Create a grid of values for x, y, and t
X1V = linspace(min(X1), max(X1), 100); % Adjust the range and resolution as needed
X2V = linspace(min(X2), max(X2), 100);
X3V = linspace(min(X3), max(X3), 100);
[X, Y,T] = ndgrid(X1V, X2V,X3V);
F = scatteredInterpolant(X1V, X2V, X3V);
Z = F(X, Y, T);
% Create a 3D surface plot
figure;
surf(X1, X2, X3, Z);
xlabel('X');
ylabel('Y');
zlabel('T');
title('3D Surface Plot of z = f(x, y, t)');
Error getting is
Error using scatteredInterpolant
The input points must be specified in column-vector format.
Error in Project3 (line 44)
F = scatteredInterpolant(X1V, X2V, X3V);
0 comentarios
Respuestas (1)
Star Strider
el 23 de Oct. de 2023
I do not have your data so I am not certain exactly what the problem is.
A relatively easy way to create column vectors is:
F = scatteredInterpolant(X1V(:), X2V(:), X3V(:));
The ‘(:)’ operator subscript convention forces them to become column vectors regardless of their original dimensions, whether vectors or matrices.
4 comentarios
Star Strider
el 23 de Oct. de 2023
Provide MainData.xlsx. Stopping here until I have access to it, since I cannot proceed without it. Use the ‘paperclip’ icon to upload it.
You can plot three dimmensions in MATLAB, not four, which is what you appear to want to do. To plot a fourth dimension (such as time), you will need to stack the 3D plots or plot separate 3D plots, with each ‘layer’ (or colour or axes, depending on how you want to approach this) being a different time instant, depending on how you want to plot the data.
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!