http://www.mathworks.com/matlabcentral/newsreader/view_thread/291116
MATLAB Central Newsreader  Two vectors different dimensions
Feed for thread: Two vectors different dimensions
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Tue, 07 Sep 2010 20:15:06 +0000
Two vectors different dimensions
http://www.mathworks.com/matlabcentral/newsreader/view_thread/291116#777681
Aaron Anstey
I have a information for elevation (metres) along a road at certain distances from origin and also vectors for speed and power, measured at different distances.<br>
<br>
I need to somehow link both the tables and it may mean using bins at 12 metre intervals or round each point up. Any hints or tips to do this would be appreciated. Distance is the only common variable between the two tables.<br>
Distance Elevation<br>
1.2 24<br>
2.3 26<br>
4.5 32 <br>
<br>
distance Time Power Speed<br>
1.5 1 0.5 10<br>
2 .7 2 0.7 15<br>
3.2 3 0.3 16<br>
<br>
Thanks

Tue, 07 Sep 2010 21:15:27 +0000
Re: Two vectors different dimensions
http://www.mathworks.com/matlabcentral/newsreader/view_thread/291116#777695
Oleg Komarov
"Aaron Anstey" <elaja2@lboro.ac.uk> wrote in message <i666ga$1u$1@fred.mathworks.com>...<br>
> I have a information for elevation (metres) along a road at certain distances from origin and also vectors for speed and power, measured at different distances.<br>
> <br>
> I need to somehow link both the tables and it may mean using bins at 12 metre intervals or round each point up. Any hints or tips to do this would be appreciated. Distance is the only common variable between the two tables.<br>
> Distance Elevation<br>
> 1.2 24<br>
> 2.3 26<br>
> 4.5 32 <br>
> <br>
> distance Time Power Speed<br>
> 1.5 1 0.5 10<br>
> 2 .7 2 0.7 15<br>
> 3.2 3 0.3 16<br>
> <br>
> Thanks<br>
<br>
A = [1.2 24<br>
2.3 26<br>
4.5 32];<br>
<br>
B = [1.5 1 0.5 10<br>
2.7 2 0.7 15<br>
3.2 3 0.3 16];<br>
<br>
maxBin = ceil(max([A(:,1); B(:,1)]));<br>
minBin = floor(min([A(:,1); B(:,1)]));<br>
[trash, locA] = histc(A(:,1),minBin:maxBin);<br>
[trash, locB] = histc(B(:,1),minBin:maxBin);<br>
<br>
C = NaN(maxBinminBin,5);<br>
C(locA,1:2) = A;<br>
C(locB,[1,3:end]) = B;<br>
<br>
C =<br>
1.50 24.00 1.00 0.50 10.00<br>
2.70 26.00 2.00 0.70 15.00<br>
3.20 NaN 3.00 0.30 16.00<br>
4.50 32.00 NaN NaN NaN

Wed, 08 Sep 2010 02:28:04 +0000
Re: Two vectors different dimensions
http://www.mathworks.com/matlabcentral/newsreader/view_thread/291116#777745
Roger Stafford
"Aaron Anstey" <elaja2@lboro.ac.uk> wrote in message <i666ga$1u$1@fred.mathworks.com>...<br>
> I have a information for elevation (metres) along a road at certain distances from origin and also vectors for speed and power, measured at different distances.<br>
> <br>
> I need to somehow link both the tables and it may mean using bins at 12 metre intervals or round each point up. Any hints or tips to do this would be appreciated. Distance is the only common variable between the two tables.<br>
> Distance Elevation<br>
> 1.2 24<br>
> 2.3 26<br>
> 4.5 32 <br>
> <br>
> distance Time Power Speed<br>
> 1.5 1 0.5 10<br>
> 2 .7 2 0.7 15<br>
> 3.2 3 0.3 16<br>
> <br>
> Thanks<br>
         <br>
I would think you need the services of matlab's interp1 function. You probably would wish to set the options so as to allow extrapolation as well as interpolation for your problem. Read the documentation carefully to explore its possibilities.<br>
<br>
Roger Stafford

Wed, 08 Sep 2010 08:44:05 +0000
Re: Two vectors different dimensions
http://www.mathworks.com/matlabcentral/newsreader/view_thread/291116#777789
Aaron Anstey
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <i66sbk$l88$1@fred.mathworks.com>...<br>
> "Aaron Anstey" <elaja2@lboro.ac.uk> wrote in message <i666ga$1u$1@fred.mathworks.com>...<br>
> > I have a information for elevation (metres) along a road at certain distances from origin and also vectors for speed and power, measured at different distances.<br>
> > <br>
> > I need to somehow link both the tables and it may mean using bins at 12 metre intervals or round each point up. Any hints or tips to do this would be appreciated. Distance is the only common variable between the two tables.<br>
> > Distance Elevation<br>
> > 1.2 24<br>
> > 2.3 26<br>
> > 4.5 32 <br>
> > <br>
> > distance Time Power Speed<br>
> > 1.5 1 0.5 10<br>
> > 2 .7 2 0.7 15<br>
> > 3.2 3 0.3 16<br>
> > <br>
> > Thanks<br>
>          <br>
> I would think you need the services of matlab's interp1 function. You probably would wish to set the options so as to allow extrapolation as well as interpolation for your problem. Read the documentation carefully to explore its possibilities.<br>
> <br>
> Roger Stafford<br>
<br>
Thanks Roger that works.

Wed, 08 Sep 2010 09:21:05 +0000
Re: Two vectors different dimensions
http://www.mathworks.com/matlabcentral/newsreader/view_thread/291116#777794
Mashhur
"Aaron Anstey" <elaja2@lboro.ac.uk> wrote in message <i666ga$1u$1@fred.mathworks.com>...<br>
> I have a information for elevation (metres) along a road at certain distances from origin and also vectors for speed and power, measured at different distances.<br>
> <br>
> I need to somehow link both the tables and it may mean using bins at 12 metre intervals or round each point up. Any hints or tips to do this would be appreciated. Distance is the only common variable between the two tables.<br>
> Distance Elevation<br>
> 1.2 24<br>
> 2.3 26<br>
> 4.5 32 <br>
> <br>
> distance Time Power Speed<br>
> 1.5 1 0.5 10<br>
> 2 .7 2 0.7 15<br>
> 3.2 3 0.3 16<br>
> <br>
> Thanks<br>
<br>
if I am right you can use A[]' + B[]' (decrement and multiply or other operations also possible). I had done it by applying like this. It automatically fills by zero lack of array arguments.<br>
Second approach, use imfill() function in Matlab if you are using images.<br>
<br>
Enjoy,