Interpolation input grid is not a valid meshgrid

11 views (last 30 days)
Hi,
I'm quite new to MATLAB and i can't figure out what i'm doing wrong.
omega=... % speed in rad/s
((1/3.6)/0.0625)*[2 2 2 2 2;
4 4 4 4 4;
6 6 6 6 6;
8 8 8 8 8;
10 10 10 10 10;
12 12 12 12 12;
14 14 14 14 14;
16 16 16 16 16;
18 18 18 18 18;
20 20 20 20 20;
22 22 22 22 22;
24 24 24 24 24;
26 26 26 26 26;
28 28 28 28 28;
30 30 30 30 30;
32 32 32 32 32;
34 34 34 34 34;
36 36 36 36 36;
38 38 38 38 38];
torque=... % torque in Nm
0.04*[5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ;
5 7 10 13 15 ];
eta=... % measured efficiency
[0.1025 0.1440 0.1824 0.2076 0.2190 ;
0.1338 0.1929 0.2463 0.2804 0.2975 ;
0.1461 0.2147 0.2790 0.3267 0.3378 ;
0.1246 0.2255 0.2658 0.3470 0.3414 ;
0.1380 0.2254 0.2919 0.3724 0.3691 ;
0.1427 0.2501 0.3000 0.3840 0.5545 ;
0.3453 0.4437 0.5122 0.3896 0.5680 ;
0.3439 0.4464 0.5247 0.3944 0.5810 ;
0.3435 0.4549 0.5319 0.3968 0.5883 ;
0.3487 0.4659 0.5449 0.4005 0.6039 ;
0.3462 0.2500 0.5521 0.4071 0.6104 ;
0.1481 0.2423 0.3356 0.4058 0.4239 ;
0.1495 0.2480 0.3382 0.4070 0.4213 ;
0.1491 0.2491 0.3359 0.4097 0.4186 ;
0.1516 0.2531 0.3456 0.4122 0.4195 ;
0.1514 0.2573 0.3478 0.4330 0.4042 ;
0.1507 0.2584 0.3532 0.4232 0.3923 ;
0.1523 0.2582 0.3540 0.4252 0.3999 ;
0.1463 0.2617 0.3572 0.4267 0.4923 ];
%Interpolate to refine data
[omega_q , torque_q]=meshgrid ((((1/3.6)/0.0625)*2):((1/3.6)/0.0625):(((1/3.6)/0.0625)*38), (5*0.04):0.04:(15*0.04)); % set refined points
eta_q=interp2(omega, torque , eta , omega_q , torque_q, 'cubic'); % do cubic interpolation
I know I defined the meshgrid in a really weird way. But i just don't know what to do. If someone could help I would be really gratefull.
Thanks in advance!
Thom Nelissen

Accepted Answer

Stephen23
Stephen23 on 21 Dec 2021
Edited: Stephen23 on 21 Dec 2021
You mixed up the dimensions. This follows the explanation and examples in the INTERP2 documentation:
omega = ((1/3.6)/0.0625)*[2,2,2,2,2;4,4,4,4,4;6,6,6,6,6;8,8,8,8,8;10,10,10,10,10;12,12,12,12,12;14,14,14,14,14;16,16,16,16,16;18,18,18,18,18;20,20,20,20,20;22,22,22,22,22;24,24,24,24,24;26,26,26,26,26;28,28,28,28,28;30,30,30,30,30;32,32,32,32,32;34,34,34,34,34;36,36,36,36,36;38,38,38,38,38]
omega = 19×5
8.8889 8.8889 8.8889 8.8889 8.8889 17.7778 17.7778 17.7778 17.7778 17.7778 26.6667 26.6667 26.6667 26.6667 26.6667 35.5556 35.5556 35.5556 35.5556 35.5556 44.4444 44.4444 44.4444 44.4444 44.4444 53.3333 53.3333 53.3333 53.3333 53.3333 62.2222 62.2222 62.2222 62.2222 62.2222 71.1111 71.1111 71.1111 71.1111 71.1111 80.0000 80.0000 80.0000 80.0000 80.0000 88.8889 88.8889 88.8889 88.8889 88.8889
torque = 0.04*[5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15;5,7,10,13,15]
torque = 19×5
0.2000 0.2800 0.4000 0.5200 0.6000 0.2000 0.2800 0.4000 0.5200 0.6000 0.2000 0.2800 0.4000 0.5200 0.6000 0.2000 0.2800 0.4000 0.5200 0.6000 0.2000 0.2800 0.4000 0.5200 0.6000 0.2000 0.2800 0.4000 0.5200 0.6000 0.2000 0.2800 0.4000 0.5200 0.6000 0.2000 0.2800 0.4000 0.5200 0.6000 0.2000 0.2800 0.4000 0.5200 0.6000 0.2000 0.2800 0.4000 0.5200 0.6000
eta = [0.1025,0.1440,0.1824,0.2076,0.2190;0.1338,0.1929,0.2463,0.2804,0.2975;0.1461,0.2147,0.2790,0.3267,0.3378;0.1246,0.2255,0.2658,0.3470,0.3414;0.1380,0.2254,0.2919,0.3724,0.3691;0.1427,0.2501,0.3000,0.3840,0.5545;0.3453,0.4437,0.5122,0.3896,0.5680;0.3439,0.4464,0.5247,0.3944,0.5810;0.3435,0.4549,0.5319,0.3968,0.5883;0.3487,0.4659,0.5449,0.4005,0.6039;0.3462,0.2500,0.5521,0.4071,0.6104;0.1481,0.2423,0.3356,0.4058,0.4239;0.1495,0.2480,0.3382,0.4070,0.4213;0.1491,0.2491,0.3359,0.4097,0.4186;0.1516,0.2531,0.3456,0.4122,0.4195;0.1514,0.2573,0.3478,0.4330,0.4042;0.1507,0.2584,0.3532,0.4232,0.3923;0.1523,0.2582,0.3540,0.4252,0.3999;0.1463,0.2617,0.3572,0.4267,0.4923]
eta = 19×5
0.1025 0.1440 0.1824 0.2076 0.2190 0.1338 0.1929 0.2463 0.2804 0.2975 0.1461 0.2147 0.2790 0.3267 0.3378 0.1246 0.2255 0.2658 0.3470 0.3414 0.1380 0.2254 0.2919 0.3724 0.3691 0.1427 0.2501 0.3000 0.3840 0.5545 0.3453 0.4437 0.5122 0.3896 0.5680 0.3439 0.4464 0.5247 0.3944 0.5810 0.3435 0.4549 0.5319 0.3968 0.5883 0.3487 0.4659 0.5449 0.4005 0.6039
%Interpolate to refine data
V1 = (5*0.04):0.04:(15*0.04);
V2 = ((1/3.6)/0.0625)*2:(1/3.6)/0.0625:((1/3.6)/0.0625)*38;
[torque_q,omega_q] = meshgrid(V1, V2) % swap the order here !!!!
torque_q = 37×11
0.2000 0.2400 0.2800 0.3200 0.3600 0.4000 0.4400 0.4800 0.5200 0.5600 0.6000 0.2000 0.2400 0.2800 0.3200 0.3600 0.4000 0.4400 0.4800 0.5200 0.5600 0.6000 0.2000 0.2400 0.2800 0.3200 0.3600 0.4000 0.4400 0.4800 0.5200 0.5600 0.6000 0.2000 0.2400 0.2800 0.3200 0.3600 0.4000 0.4400 0.4800 0.5200 0.5600 0.6000 0.2000 0.2400 0.2800 0.3200 0.3600 0.4000 0.4400 0.4800 0.5200 0.5600 0.6000 0.2000 0.2400 0.2800 0.3200 0.3600 0.4000 0.4400 0.4800 0.5200 0.5600 0.6000 0.2000 0.2400 0.2800 0.3200 0.3600 0.4000 0.4400 0.4800 0.5200 0.5600 0.6000 0.2000 0.2400 0.2800 0.3200 0.3600 0.4000 0.4400 0.4800 0.5200 0.5600 0.6000 0.2000 0.2400 0.2800 0.3200 0.3600 0.4000 0.4400 0.4800 0.5200 0.5600 0.6000 0.2000 0.2400 0.2800 0.3200 0.3600 0.4000 0.4400 0.4800 0.5200 0.5600 0.6000
omega_q = 37×11
8.8889 8.8889 8.8889 8.8889 8.8889 8.8889 8.8889 8.8889 8.8889 8.8889 8.8889 13.3333 13.3333 13.3333 13.3333 13.3333 13.3333 13.3333 13.3333 13.3333 13.3333 13.3333 17.7778 17.7778 17.7778 17.7778 17.7778 17.7778 17.7778 17.7778 17.7778 17.7778 17.7778 22.2222 22.2222 22.2222 22.2222 22.2222 22.2222 22.2222 22.2222 22.2222 22.2222 22.2222 26.6667 26.6667 26.6667 26.6667 26.6667 26.6667 26.6667 26.6667 26.6667 26.6667 26.6667 31.1111 31.1111 31.1111 31.1111 31.1111 31.1111 31.1111 31.1111 31.1111 31.1111 31.1111 35.5556 35.5556 35.5556 35.5556 35.5556 35.5556 35.5556 35.5556 35.5556 35.5556 35.5556 40.0000 40.0000 40.0000 40.0000 40.0000 40.0000 40.0000 40.0000 40.0000 40.0000 40.0000 44.4444 44.4444 44.4444 44.4444 44.4444 44.4444 44.4444 44.4444 44.4444 44.4444 44.4444 48.8889 48.8889 48.8889 48.8889 48.8889 48.8889 48.8889 48.8889 48.8889 48.8889 48.8889
eta_q = interp2(torque, omega, eta, torque_q, omega_q, 'spline') % do cubic interpolation
eta_q = 37×11
0.1025 0.1254 0.1440 0.1592 0.1717 0.1824 0.1919 0.2003 0.2076 0.2138 0.2190 0.1171 0.1493 0.1729 0.1902 0.2032 0.2144 0.2255 0.2363 0.2466 0.2557 0.2632 0.1338 0.1665 0.1929 0.2143 0.2317 0.2463 0.2591 0.2704 0.2804 0.2894 0.2975 0.1457 0.1777 0.2061 0.2309 0.2523 0.2704 0.2854 0.2976 0.3076 0.3157 0.3223 0.1461 0.1842 0.2147 0.2394 0.2602 0.2790 0.2971 0.3134 0.3267 0.3353 0.3378 0.1331 0.1873 0.2207 0.2408 0.2549 0.2703 0.2923 0.3168 0.3378 0.3490 0.3443 0.1246 0.1900 0.2255 0.2425 0.2521 0.2658 0.2912 0.3217 0.3470 0.3570 0.3414 0.1340 0.1935 0.2289 0.2493 0.2639 0.2819 0.3091 0.3386 0.3598 0.3626 0.3366 0.1380 0.1903 0.2254 0.2498 0.2698 0.2919 0.3202 0.3495 0.3724 0.3814 0.3691 0.1219 0.1810 0.2182 0.2415 0.2588 0.2780 0.3055 0.3403 0.3800 0.4219 0.4636

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!