Path: news.mathworks.com!not-for-mail
From: "Sadik " <sadik.hava@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Converting Matrix Dimensions?
Date: Mon, 19 Jan 2009 00:43:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 59
Message-ID: <gl0ial$deu$1@fred.mathworks.com>
References: <gktk1p$7ak$1@fred.mathworks.com> <gkvjgd$e4c$1@fred.mathworks.com> <gl0hap$83m$1@fred.mathworks.com>
Reply-To: "Sadik " <sadik.hava@gmail.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1232325781 13790 172.30.248.38 (19 Jan 2009 00:43:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 19 Jan 2009 00:43:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1666517
Xref: news.mathworks.com comp.soft-sys.matlab:512362


"Jens Doe" <jerald29@hotmail.com> wrote in message <gl0hap$83m$1@fred.mathworks.com>...
> Thank you for your help so far. However, I can not get either of these two codes to work. I'll post my code for both
> 
> using (:).'
> 
> numbers=input('What data file would you like to load? ','s')
>     
>     load(numbers)
>     
>     numbers(:).'
>     
>     allnumbers=numbers(:).'
>     
>     length(allnumbers)
>     
>     l=length(allnumbers)
>     
>     disp(['Length of data ' num2str(l)])
>     
>    sum(allnumbers)
>    
>    s=sum(allnumbers)
>    
>    mean=s/l
>    
>    disp(['Your mean is ' num2str(mean)])
> 
> Two things that are wrong with this. It says that the length of the data is 10 instead of 80 and it says the sum is 915 instead of 6477. 
> 
> 
> Then using the reshape(A,[],1)
> 
> clear
> clc
> 
> data=input('What file would you like to load? ','s')
> 
> load(data)
> 
> a=reshape(data,[],1)
> 
> disp(['Length of data ' num2str(a)])
> 
> 
> With this I'm getting an error of 
> ??? Error using ==> horzcat
> CAT arguments dimensions are not consistent.
> 
> I'm not too sure whats wrong with either.

Hello Jens,

For the first method, please make sure that you are loading the correct file. It seems that you are not loading the original data which is 20x4. 

For the second method, yes, it will give error. This is because, given that it will load the same thing with 10 elements, your vector a will be 10x1 and you would not be able to concatenate a 10-element vector with a row string. This should help:

disp(['Length of data ' num2str(length(a))])

Hope this helps.