Plot a surface graph and interpolate between 2 variables

Hello all, thank you for taking the time to read my question, I am quite new to MATLAB)
So I have a material made from a blend of 2 concentrations of A and B. The concentrations of A used is (2.5% and 5%) and B is (1% and 1.5%). A matrix is formed when measuring the properties of each of the different combinations of the two blends. As shown below. The numerical results in green of the different combinations are c,d,e,f for example.
Now I would like to plot a 3D surface plot with A concentration on the x, B concentration on the y and the results on the z axis. How would I do that? I read about a meshgrid or plot3 function?
Also my other question is that now I have been given a numerical result and would like to interpolate to find the optimal concentration of A and B in the material respectively that can create this number, how would I do that?
Many thanks for your help!!

 채택된 답변

Ameer Hamza
Ameer Hamza 2020년 5월 22일
You can plot a surface using something like this
A_conc = [2.5 5];
B_conc = [1 1.5];
M = [1 2;
1.5 2.5];
surf(A_conc, B_conc, M)
Similarly, to interpolate the data, you can use interp2
M_interp = interp2(A_conc, B_conc, M, 3, 1.25, 'spline') % spline interpolation

댓글 수: 8

Thank you for your reply, the first part really helped. Is there any way to change the colour from Purple?
Also for the interpolate/extrapolate part of the question. I am given a value within M (or maybe beyond the range of values in M) and need to find the A_conc and B_conc that will produce this new value, how would I do that. As I think your answer is interpolating assuming I have A_conc and B_conc.
Thanks a lot!
You can try the shading option to have a variable color
A_conc = [2.5 5];
B_conc = [1 1.5];
M = [1 2;
1.5 2.5];
surf(A_conc, B_conc, M)
shading interp
also you can use a different colormap
A_conc = [2.5 5];
B_conc = [1 1.5];
M = [1 2;
1.5 2.5];
surf(A_conc, B_conc, M)
shading interp
colormap(jet)
Thank you very much for taking the time to answer my question!
I just notice your second question too. I am not sure if interpolating will be helpful. There can be an infinite number of points outside the given region which can map to the same point, especially since the point can lie at any side of the region. If you have a mathematical model of the surface, then it might be helpful.
Ok I see thanks, assuming my surface plot will just be a flat surface like the picture in the 1st photo can it not just be extended? I am trying to find the value of A_conc and B_conc when my value of M =0.4 essentially. So I assume if the surface plot covers a greater range I may be able to rudimentarily find it by clicking on my extended surface plot? Though I am not sure its possible.
Yes, it is possible to extrapolate the surface and find a solution (see the answer to your other question). However, the solution is not unique. For example, consider the following plot
The plane at z=1.7 intersects the surface of your matrix at several points. Which one of those points do you want to find out?
Ah ok, I completely understand now from the diagram, thank you so much for taking the time to answer my question!
I am glad to be of help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2020년 5월 22일

댓글:

2020년 5월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by