3D interpolation on table with 3 variables on MATLAB

6 Ansichten (letzte 30 Tage)
Hugh Jass
Hugh Jass am 30 Nov. 2020
Beantwortet: amin am 30 Nov. 2020
This is my second program on matlab and I'm not sure how to do this as the tutorials online take all the variables seperately. I have a table that looks like below. The first row is an axis and the first column is another axis. For example I would like to get the z value where x = 2900 and y=45, so I would be interpolating between the values
1300 2600 3750 4500 5800 7100 8400 9700 11000 12300 13000
25 0.096234615 0.239117308 0.385056 0.487474444 0.675744828 0.874833803 1.082447024 1.296634021 1.516019091 1.739652846 1.861441923
40 1.511103846 1.893471154 2.130796 2.259105556 2.44990431 2.612664789 2.755516071 2.883509278 2.999915455 3.106855691 3.161123462
50 1.522857692 1.911469231 2.153716 2.284784444 2.480200862 2.647233099 2.794057143 2.925745876 3.045581818 3.155847967 3.211885385
65 3.2499565
70 1.536080769 1.932405769 2.180456 2.315132222 2.515931034 2.687854225 2.839305952 2.975464948 3.099495909 3.213846748 3.271903462
75 1.538284615 1.936078846 2.18504 2.320225556 2.522023276 2.694714085 2.847036905 2.983931959 3.108698636 3.223707317 3.282188077
89 2.761419231 2.986578846 3.182314667 3.308544444 3.524443966 3.736471127 3.944945833 4.149721134 4.350806364
107 3.320461538 3.590432692 3.826112 3.977681111 4.237236207 4.492266197 4.742825595 4.989038144
132 4.096215385 4.429363462 4.719992 4.907214444 5.227143103 5.541824648 5.850966667
158 4.902823077 5.302086538 5.64978 5.873674444 6.256731897 6.633349296
172 5.336980769 5.771873077 6.1502 6.394043333 6.811125862 7.22114507
194 7.255061538 6.611538462 6.243153333 6.10436 6.053547414
232 8.675807692 7.906665385 7.466062667 7.30002 7.239393966
250 10.04953846 9.052298077 8.514525333 8.338423333
275 11.05449231 9.957344231 9.366130667 9.172244444
310 13.30755769 11.71417692 10.73216267 10.30784556
348 14.93913846 13.15035 12.04777067

Akzeptierte Antwort

amin
amin am 30 Nov. 2020
Hi Hugh,
I am not sure about the Z matrix, and I replaced 0 in the empty positions, and of course, you can change it. For instance, at the fourth row of matrix Z, I assumed that all the elements are zero except the fourth one. In the end, I added a part to plot the data and visualise it.
I hope it helps!
x=[25 40 50 65 70 75 89 107 132 158 172 194 232 250 275 310 348];
y=[1300 2600 3750 4500 5800 7100 8400 9700 11000 12300 13000];
Z=[ 0.096234615 0.239117308 0.385056 0.487474444 0.675744828 0.874833803 1.082447024 1.296634021 1.516019091 1.739652846 1.861441923;
1.511103846 1.893471154 2.130796 2.259105556 2.44990431 2.612664789 2.755516071 2.883509278 2.999915455 3.106855691 3.161123462;
1.522857692 1.911469231 2.153716 2.284784444 2.480200862 2.647233099 2.794057143 2.925745876 3.045581818 3.155847967 3.211885385;
0 0 0 3.2499565 0 0 0 0 0 0 0;
1.536080769 1.932405769 2.180456 2.315132222 2.515931034 2.687854225 2.839305952 2.975464948 3.099495909 3.213846748 3.271903462;
1.538284615 1.936078846 2.18504 2.320225556 2.522023276 2.694714085 2.847036905 2.983931959 3.108698636 3.223707317 3.282188077;
2.761419231 2.986578846 3.182314667 3.308544444 3.524443966 3.736471127 3.944945833 4.149721134 4.350806364 0 0 ;
3.320461538 3.590432692 3.826112 3.977681111 4.237236207 4.492266197 4.742825595 4.989038144 0 0 0 ;
4.096215385 4.429363462 4.719992 4.907214444 5.227143103 5.541824648 5.850966667 0 0 0 0 ;
4.902823077 5.302086538 5.64978 5.873674444 6.256731897 6.633349296 0 0 0 0 0 ;
5.336980769 5.771873077 6.1502 6.394043333 6.811125862 7.22114507 0 0 0 0 0 ;
7.255061538 6.611538462 6.243153333 6.10436 6.053547414 0 0 0 0 0 0 ;
8.675807692 7.906665385 7.466062667 7.30002 7.239393966 0 0 0 0 0 0 ;
10.04953846 9.052298077 8.514525333 8.338423333 0 0 0 0 0 0 0 ;
11.05449231 9.957344231 9.366130667 9.172244444 0 0 0 0 0 0 0 ;
13.30755769 11.71417692 10.73216267 10.30784556 0 0 0 0 0 0 0 ;
14.93913846 13.15035 12.04777067 0 0 0 0 0 0 0 0 ];
%Interploated value at 45 and 2900:
interp2(y,x,Z,2900,45)
%Plot the graph:
[X,Y] = meshgrid(x,y);
Zq = interp2(y,x,Z,Y,X);
surf(Y,X,Zq)

Weitere Antworten (0)

Kategorien

Mehr zu Interpolation finden Sie in Help Center und File Exchange

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by