Quantcast
Channel: MATLAB Central Newsreader - tag:"find"
Viewing all articles
Browse latest Browse all 55

Re: to find the value in between two points corresponding to a particular value of two points or numbers

$
0
0
"Maneesh T" wrote in message <n41scj$7ho$1@newscl01ah.mathworks.com>...
> angle gain
> 180 5.9000
> 179 5.8000 suppose i would like to have value of 174.4 ,I would like to know corresp
> 178 5.6000 -onding gain it will be in between 4.2 and 4.6. But how to find out the value
> 177 5.5000 . I want to generalize it for different angles. so we will get particular gains.
> 176 5.1000 I think we can do using slope method but how to do? any method is OK .
> 175 4.6000
> 174 4.2000
> 173 3.5000
> 172 2.8000
> 171 1.7000
> 170 0.5000
> 169 -0.9000
> 168 -2.8000
> 167 -3.9000
> 166 -5.3000
> 165 -6.4000
> 164 -8.3000
> 163 -10.1000
> 162 -13.9000
> 161 -17.6000
> 160 -25.7000
> 159 -23.2000
> 158 -18
> 157 -13.4000
> 156 -10.6000
> 155 -9.3000
> 154 -8.8000
> 153 -8.5000
> 152 -8.6000
> 151 -9.4000
> 150 -10.5000
> 149 -13.1000
> 148 -15.9000
> 147 -23.7000
> 146 -32.1000
> 145 -22.4000
> 144 -19.1000
> 143 -17.1000
> 142 -16.3000
> 141 -14.9000
> 140 -13.4000
> 139 -12.1000
> 138 -11.2000
> 137 -9.9000
> 136 -9.1000
> 135 -8.8000
> 134 -8.4000
> 133 -8.2000
> 132 -8.1000
> 131 -8.2000
> 130 -8.5000
> 129 -8.7000
> 128 -9.2000
> 127 -9.6000
> 126 -9.9000
> 125 -10.5000
> 124 -10.9000
> 123 -11.9000
> 122 -13.2000
> 121 -14.3000
> 120 -15.4000
> 119 -16.5000
> 118 -17.8000
> 117 -17.9000
> 116 -17.4000
> 115 -17.1000
> 114 -15.7000
> 113 -14.8000
> 112 -13.6000
> 111 -12.8000
> 110 -12
> 109 -11.6000
> 108 -11
> 107 -10.5000
> 106 -10.4000
> 105 -10.4000
> 104 -10.4000
> 103 -10.6000
> 102 -10.8000
> 101 -11
> 100 -11.4000
> 99 -12.2000
> 98 -12.5000
> 97 -13.2000
> 96 -13.9000
> 95 -14.8000
> 94 -15.4000
> 93 -16.4000
> 92 -16.9000
> 91 -18.3000
> 90 -19.4000
> 89 -20.9000
> 88 -22
> 87 -23.5000
> 86 -24.1000
> 85 -24.8000
> 84 -24.2000
> 83 -23.3000
> 82 -22.4000
> 81 -21
> 80 -19.2000
> 79 -18.6000
> 78 -17.3000
> 77 -16.5000
> 76 -15.8000
> 75 -15.5000
> 74 -15.6000
> 73 -15.5000
> 72 -15.4000
> 71 -15.7000
> 70 -16.1000
> 69 -15.9000
> 68 -15.9000
> 67 -15.7000
> 66 -15.4000
> 65 -15.2000
> 64 -14.8000
> 63 -14.6000
> 62 -14.4000
> 61 -14
> 60 -13.7000
> 59 -13.5000
> 58 -13.2000
> 57 -12.6000
> 56 -11.8000
> 55 -11.1000
> 54 -9.9000
> 53 -9.1000
> 52 -8.2000
> 51 -7.7000
> 50 -7.4000
> 49 -7.4000
> 48 -7.8000
> 47 -8.3000
> 46 -9.5000
> 45 -10.6000
> 44 -12.7000
> 43 -14.7000
> 42 -16.1000
> 41 -16.1000
> 40 -15.4000
> 39 -14.3000
> 38 -13.9000
> 37 -14.1000
> 36 -15.1000
> 35 -17.2000
> 34 -20.5000
> 33 -31.9000
> 32 -28.4000
> 31 -17.4000
> 30 -14.2000
> 29 -10.9000
> 28 -9.5000
> 27 -8.4000
> 26 -8.2000
> 25 -8.6000
> 24 -9.2000
> 23 -10.8000
> 22 -12.1000
> 21 -15.5000
> 20 -18.7000
> 19 -20.4000
> 18 -16
> 17 -10.6000
> 16 -7.9000
> 15 -5.2000
> 14 -3.6000
> 13 -1.8000
> 12 -0.7000
> 11 0.7000
> 10 1.5000
> 9 2.3000
> 8 3
> 7 3.6000
> 6 4.3000
> 5 4.6000
> 4 5.1000
> 3 5.4000
> 2 5.6000
> 1 5.9000
> 0 6
> -1 5.9000
> -2 5.8000
> -3 5.5000
> -4 5.3000
> -5 4.9000
> -6 3.7000
> -7 3
> -8 2.4000
> -9 1.6000
> -10 0.3000
> -11 -0.7000
> -12 -2.4000
> -13 -4.2000
> -14 -4.4000
> -15 -5.3000
> -16 -5.7000
> -17 -5.7000
> -18 -5.2000
> -19 -5.1000
> -20 -5
> -21 -4.9000
> -22 -4.7000
> -23 -4.4000
> -24 -4.4000
> -25 -4.3000
> -26 -4.7000
> -27 -5
> -28 -5.8000
> -29 -7
> -30 -7.9000
> -31 -9.2000
> -32 -10.9000
> -33 -11.3000
> -34 -11.5000
> -35 -10.6000
> -36 -9.2000
> -37 -8.5000
> -38 -7.8000
> -39 -7.9000
> -40 -7.9000
> -41 -8.9000
> -42 -10
> -43 -11.7000
> -44 -13.3000
> -45 -14.1000
> -46 -12.6000
> -47 -11.4000
> -48 -9.9000
> -49 -8.7000
> -50 -7.9000
> -51 -7.6000
> -52 -7.7000
> -53 -8
> -54 -8.4000
> -55 -9.2000
> -56 -10
> -57 -11.4000
> -58 -12.5000
> -59 -14.7000
> -60 -16.6000
> -61 -19.8000
> -62 -25.1000
> -63 -29.2000
> -64 -24.3000
> -65 -20.9000
> -66 -18
> -67 -15.6000
> -68 -13.3000
> -69 -12.1000
> -70 -11
> -71 -10.3000
> -72 -9.5000
> -73 -9.5000
> -74 -9.1000
> -75 -9
> -76 -8.9000
> -77 -9.1000
> -78 -9.4000
> -79 -9.5000
> -80 -10
> -81 -10.9000
> -82 -11.2000
> -83 -11.9000
> -84 -12.5000
> -85 -13.4000
> -86 -14.2000
> -87 -15.7000
> -88 -17.6000
> -89 -18.7000
> -90 -21.3000
> -91 -23.8000
> -92 -25.4000
> -93 -25
> -94 -22.7000
> -95 -20.6000
> -96 -19.3000
> -97 -17.5000
> -98 -16.1000
> -99 -15.2000
> -100 -14.6000
> -101 -14
> -102 -13.2000
> -103 -12.8000
> -104 -12.6000
> -105 -12
> -106 -11.8000
> -107 -11.6000
> -108 -11.8000
> -109 -12.1000
> -110 -12.4000
> -111 -13
> -112 -13.6000
> -113 -14
> -114 -14.8000
> -115 -15.7000
> -116 -16.3000
> -117 -17.1000
> -118 -17.8000
> -119 -17.7000
> -120 -16.7000
> -121 -15.1000
> -122 -13.5000
> -123 -12.4000
> -124 -11.2000
> -125 -10.7000
> -126 -10.1000
> -127 -10
> -128 -10.1000
> -129 -10.3000
> -130 -10.7000
> -131 -11.5000
> -132 -12.2000
> -133 -12.5000
> -134 -12.3000
> -135 -12.1000
> -136 -10.8000
> -137 -9.9000
> -138 -9.3000
> -139 -8.7000
> -140 -8.4000
> -141 -8.1000
> -142 -7.9000
> -143 -8
> -144 -8.3000
> -145 -8.6000
> -146 -8.9000
> -147 -8.6000
> -148 -8.2000
> -149 -7.3000
> -150 -6.6000
> -151 -5.7000
> -152 -5.4000
> -153 -5.1000
> -154 -4.8000
> -155 -4.5000
> -156 -4.3000
> -157 -4
> -158 -3.9000
> -159 -3.7000
> -160 -3.7000
> -161 -3.9000
> -162 -4.2000
> -163 -4.8000
> -164 -5.1000
> -165 -5.4000
> -166 -5
> -167 -3.8000
> -168 -2.1000
> -169 -0.9000
> -170 0.6000
> -171 1.3000
> -172 2.4000
> -173 3
> -174 3.7000
> -175 4.9000
> -176 5.3000
> -177 5.5000
> -178 5.7000
> -179 5.9000

See help file for the interp1 command
http://www.mathworks.com/help/matlab/ref/interp1.html

Save your data in a file. For the code sample below, I saved it in
angledata.txt.

clear
%load your data - first column is angle, second column is gain
%Edit your data file to remove the text from the first line

load angledata.txt

%Assign angle to x and gain to y
x=angledata(:,1);
y=angledata(:,2);
%Create specific query points for the interpolation command
%For this case, they are spaced 0.1 units apart
xq=(180:-0.1:-179);
vq1 = interp1(x,y,xq);
plot(x,y,'o',xq,vq1,':.');
%Return index where value of 174.4 is found
%Use index to return interpolated gain value corresponding to
%angle of 174.4
[i,j]=find(xq==174.4)
vq1(j)

You can modify the above to return interpolated values of gain given a value of angle.

Regards,
Georgios

Viewing all articles
Browse latest Browse all 55

Trending Articles