Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Matrix dimensions must agree.
Replies: 13   Last Post: Mar 24, 2014 5:34 PM

 Messages: [ Previous | Next ]
 Vitor Andrade Posts: 12 Registered: 3/18/14
Re: Matrix dimensions must agree.
Posted: Mar 21, 2014 9:27 AM

"Vitor Andrade" wrote in message <lgfgag\$34p\$1@newscl01ah.mathworks.com>...
> dpb <none@non.net> wrote in message <lgfaqk\$820\$1@speranza.aioe.org>...
> > On 3/20/2014 12:57 PM, Vitor Andrade wrote:
> > ...
> >

> > > I don't understand you. I would like to delete the row that is left
> > > over. Is there anyway? I want to implement this on my code.

> >
> > Which specific row is the "leftover" one? First, last, some other based
> > on some value...?
> >
> > But, sure...that's one of the ways to implement option B --
> >
> > Assume two arrays are x and y and it's the last row to eliminate in the
> > longer array...
> >
> > lenx=length(x);
> > leny=length(y);
> > if lenx>leny
> > x(leny+1:end)=[];
> > elseif
> > if leny>lenx
> > y(lenx+1:end)=[];
> > end
> >
> > It might be simpler to prevent the two arrays from being different
> > length to begin with but that depends on how they're created.
> >
> > --
> > Thanks Sr, for your attention!

> Your code was used! Thanks again!
> >

Sr. When I was analyse other data, now, I have a new problem, the matrices with different sizes;
a = [0.400000000000000,35139.0781250000;0.933333333333333,32986.5703130000;1.50000000000000,30094.9824220000;2.26905,25000.00000;2.50000000000000,23203.3417970000;3.0666666666666,19190.0585940000;3.60000000000000, 5137.0966800000;4.16666666666667,10913.9882810000;4.80000000000000,6466.71191400000;5.36666666666667,2564.06420900000;5.86666666666667,377.535583000000]
size(a)
11x2

b = [0.633333333333333,34091.8632810000;1.23333333333333,31666.7167970000;1.73333333333333,28622.0957030000;2.23333333333333,25087.7421880000;2.76666666666667,21232.4296880000;3.33333333333333,17193.9140625000;3.86666666666667,13042.4101560000;4.46666666666667,8754.32812500000;5.10000000000000,4451.73877000000;5.66666666666667,1339.44116200000]
size(b)
10x2

>>x = length(a);
>>y = length(b);
>>
>> if x > y

a(y+1:end)=[];
else
if y > x
b(x+1:end)=[];
end
end

However, I expected to find:
a = [0.400000000000000,35139.0781250000;0.933333333333333,32986.5703130000;1.50000000000000,30094.9824220000;2.26905,25000.00000;2.50000000000000,23203.3417970000;3.0666666666666,19190.0585940000;3.60000000000000, 5137.0966800000;4.16666666666667,10913.9882810000;4.80000000000000,6466.71191400000;5.36666666666667,2564.06420900000];

And 'b' were equal.

But my result was:

a = [0.4000,0.9333,1.5000,2.0000,2.5000,3.0667,3.6000,4.1667,4.8000,5.3667];

Date Subject Author
3/20/14 dpb
3/20/14 dpb