creating 3d surface plots by iterating in for loop through different vectors

I am working on creating a 3d plot. I have these variables as matrices but I need to generate a 3d matrix with for loop iteratively and plot as seen in the below code.
In this code the plot is like a seperate vector output because it won't generate a surface, but scattered points. I would like an 3d surface plot by generating a 3d matrix with for loop iteratively. Please help me out on this!
x = Oil_Flow_Rate; % create a matrix of complex inputs
y = Oil_Temp;
z = Water_Temp;
w = TMax; % calculate the complex outputs
scatter3(x,y,z,40,w,'filled') % visualize the complex function using surf
ax = gca;
ax.XDir = 'reverse';
view(-31,14)
xlabel('Oil FlowRate [L/min]','FontWeight','Bold','FontSize',sizeW)
ylabel('Oil Temp [°C]','FontWeight','Bold','FontSize',sizeW)
zlabel('Water Temp [°C]','FontWeight','Bold','FontSize',sizeW)
cb = colorbar; % create and label the colorbar
cb.Label.String = 'TMax [°C]';

Answers (1)

In a situation like that, I would not recommend creating the entries iteratively in a loop. Instead I would suggest creating a grid of locations you want the values to be evaluated at, and use either griddata or scatteredInterpolant

1 Comment

Thanks for the response @Walter Roberson, can you say how the code is to be modified in my case. I am a beginner in Matlab please bear with me

Sign in to comment.

Products

Release

R2020b

Asked:

on 10 May 2023

Commented:

on 16 May 2023

Community Treasure Hunt

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

Start Hunting!