Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Dataset array error using "replacedata" function

Subject: Dataset array error using "replacedata" function

From: Graham

Date: 23 Nov, 2012 09:56:08

Message: 1 of 4

Hi,

I'm trying to use the function "replacedata" for a dataset array (http://www.mathworks.com/help/stats/dataset.replacedata.html). When I run the following example code:

data = dataset({rand(3,3),'Var1','Var2','Var3'})
data = replacedata(data,@zscore)

I get an error:

??? Error using ==> dataset.replacedata at 35
X must have the same number of rows as A has observations.

Please help?

Many thanks

Subject: Dataset array error using "replacedata" function

From: Peter Perkins

Date: 26 Nov, 2012 16:29:36

Message: 2 of 4

Graham, I think you are using a version of MATLAB that is older than
when that syntax that was added to the replaceData method (R2010a or b I
think). You can do the replacement in two lines, though.

Hope this helps.


On 11/23/2012 4:56 AM, Graham wrote:
> Hi,
> I'm trying to use the function "replacedata" for a dataset array
> (http://www.mathworks.com/help/stats/dataset.replacedata.html). When I
> run the following example code:
>
> data = dataset({rand(3,3),'Var1','Var2','Var3'})
> data = replacedata(data,@zscore)
>
> I get an error:
>
> ??? Error using ==> dataset.replacedata at 35
> X must have the same number of rows as A has observations.
>
> Please help?
>
> Many thanks

Subject: Dataset array error using "replacedata" function

From: rakesh8015@gmail.com

Date: 10 Nov, 2013 06:49:13

Message: 3 of 4

peter perkins:
can you post that replacement which is only two lines.

Subject: Dataset array error using "replacedata" function

From: Peter Perkins

Date: 11 Nov, 2013 20:10:05

Message: 4 of 4

On 11/10/2013 1:49 AM, rakesh8015@gmail.com wrote:
> peter perkins:
> can you post that replacement which is only two lines.
>
In your case, it would look something like

call double on the dataset to extract the data
call zscore on that
call replacedata using that

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us