From: James Ellis on 20 Mar 2010 16:13 My question is why does matlab do this? I = 1 1 1 1 >> v1=I(1,1):I(1,3) v1 = 1 How would I get v1=1 1 1 in this case? Im new to matlab and learning all the ins and outs, ive made a script which accepts a vector input such as a, b, c, d and has to make an NxN matrix a-b, -b, 0 -b, b-c, -c 0, -c, c-d which ive done as follows: I= input('Input spring constant values as a row vector:'); [m,n]=size(I); N=n-1; v1=I(1,1):I(1,N); v2=I(1,2):I(1,N+1); v3=I(1,2):I(1,N); K=diag(v1)+diag(v2)-diag(v3,1)-diag(v3,-1); The problem is if the input vector's elements are all equal matlab just makes it a number and K comes out in the wrong dimension (its used later in multiplication so it needs to be the right dimensions). Any advice?
From: Walter Roberson on 20 Mar 2010 16:17 James Ellis wrote: > My question is why does matlab do this? > > I = > > 1 1 1 1 > >>> v1=I(1,1):I(1,3) > > v1 = > > 1 > > How would I get v1=1 1 1 in this case? v1 = I(1,1:3);
From: James Ellis on 20 Mar 2010 17:06 Walter Roberson <roberson(a)hushmail.com> wrote in message <ho3agt$jdp$1(a)canopus.cc.umanitoba.ca>... > James Ellis wrote: > > My question is why does matlab do this? > > > > I = > > > > 1 1 1 1 > > > >>> v1=I(1,1):I(1,3) > > > > v1 = > > > > 1 > > > > How would I get v1=1 1 1 in this case? > > v1 = I(1,1:3); hah classic I knew it would be something obvious. Thanks!
|
Pages: 1 Prev: Printing the Command Windows Next: Frequency Banded Input and FFT |