while using interp1 following errors found

clc
thr = [0 10 20 30 40 50 60 70 80 90 100]; % throttle
trq_new = [0 10 20 30 40 50 60 70 80 90 100 110 120]; % new torq
trq = [0 0.1 29.9 87.6 99.8 101 105.6 105.4 106.1 110 120;
0 0.1 22.8 85.6 105.2 107 110 110.5 110.3 110.31 110.4;
0 0.1 17 80.6 106.1 110 112.01 112.02 112.03 112.2 112;
0 0.1 22 82.8 106 108 108.5 110 109 110 109;
0 0.1 16 79 105 110 114 114.01 113 113.01 114;
0 0.1 16.9 82.4 108 115 120.5 120.501 120.3 120.301 120.7;
0 0.1 11.4 72 105.5 115.2 120.3 120.8 120.8 120.7 120.8;
0 0.1 9 68 103.8 112.5 115.8 115.801 116.4 116 116.4;
0 0.1 6.5 63.2 103.8 109.8 111.6 111.8 111.2 112 111.8;
0 0.1 3.1 58.7 102.3 110 110.2 110.4 110.5 110.3 110.5;
0 0.1 0.2 54.6 100.5 108.6 109.5 109.6 109.601 109.602 109.3;
0 0.1 0.2 49.3 98.1 107.2 108.5 108.501 108.502 108.503 108.504;
0 0.1 0.2 47.4 95.9 106.2 107.4 107.6 107.7 107.6 107.601;
0 0.1 0.2 44.8 94.2 104 105.7 105.8 106 106.1 106.101;
0 0.1 0.2 39.4 90.1 102.4 104.5 104.501 104.6 104.601 104.602;
0 0.1 0.2 35.8 86.4 100 102.4 102.2 102.201 102.4 102.3;
0 0.1 0.2 33 83.5 97.3 100.1 100 100.1 99.5 99;]; %torq value
mf = [0.1 0.11 0.49 1.1 1.28 1.32 1.53 1.54 1.53 1.54 1.55;
0 0.11 0.5 1.22 1.5 1.52 1.78 1.77 1.79 1.78 1.77;
0 0.1 0.47 1.28 1.66 1.72 2.01 2.011 1.99 2 2.01;
0 0.14 0.6 1.46 1.82 1.93 2.22 2.23 2.24 2.22 2.2;
0 0 0.6 1.56 2.03 2.14 2.53 2.52 2.54 2.55 2.54;
0 0 0.69 1.79 2.31 2.43 2.85 2.86 2.85 2.851 2.852;
0 0 0.63 1.74 2.45 2.75 3.12 3.11 3.1101 3.1102 3.12;
0 0 0.66 1.8 2.59 2.9 3.19 3.18 3.201 3.202 3.203;
0 0 0.64 1.84 2.83 3.02 3.25 3.29 3.3 3.8 3.3;
0 0 0.66 1.88 2.98 3.23 3.58 3.58 3.6 3.56 3.58;
0 0 0.65 1.91 3.12 3.42 3.83 3.8301 3.8302 3.84 3.82;
0 0 0.1 1.92 3.26 3.6 4.04 4.0401 4.05 4.04 4.05;
0 0 0.1 1.99 3.42 3.83 4.29 4.3 4.301 4.302 4.29;
0 0 0.1 2.05 3.64 4 4.53 4.5301 4.54 4.55 4.52;
0 0 0.1 2.01 3.74 4.22 4.74 4.75 4.76 4.75 4.74;
0 0 0.1 2.01 3.78 4.45 4.89 4.8901 4.8901 4.88 4.89;
0 0 0.1 2.02 3.83 4.61 4.95 4.97 4.96 4.97 4.97;]; %mf
for j = 1:17
thr_new(j,:) = interp1(trq(j,:),thr,trq_new,'linear','extrap')
mf_new(j,:)= interp1(thr,mf(j,:),trq_new(j,:),'linear','extrap')
new_mf_trq(j,:) = interp1(thr_new(j,:),mf_new(j,:),trq_new,'linear', 'extrap')% new mf values corr. to new torq value
end

 Accepted Answer

There is no problem with interp1. You have in your code
trq_new(j,:)
with j varying from 1 to 17
But trq_new has only 1 row (and never get more rows added), hence when j is 2, you get an error.

More Answers (0)

Categories

Find more on Interpolation in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!