Thread Subject: conversion to single = out of memory?

Subject: conversion to single = out of memory?

From: MZ

Date: 10 Jul, 2009 23:59:32

Message: 1 of 3

Strange problem.

When I create a variable this way...

tempdata = zeros(size(data));

...everything works fine. But when I modify the code in this way...

tempdata = single(zeros(size(data)));

...I get an out of memory error.

Any ideas what's going on?

Subject: conversion to single = out of memory?

From: Matt Fig

Date: 11 Jul, 2009 00:25:04

Message: 2 of 3

Try this:

tempdata = zeros(size(data),'single');

Subject: conversion to single = out of memory?

From: Titus Edelhofer

Date: 11 Jul, 2009 10:21:36

Message: 3 of 3


"MZ" <mark@nospam.void> schrieb im Newsbeitrag
news:9uidnShmm_94SMrXnZ2dnUVZ_t-dnZ2d@giganews.com...
> Strange problem.
>
> When I create a variable this way...
>
> tempdata = zeros(size(data));
>
> ...everything works fine. But when I modify the code in this way...
>
> tempdata = single(zeros(size(data)));
>
> ...I get an out of memory error.
>
> Any ideas what's going on?

I guess, I have an idea: in the second line, you create the double-zeros
matrix, and then create another single matrix where the zeros are copied to.
So in fact you have 1.5 times the memory then for the first line. Use the
'single' as suggested by Matt to directly construct the single matrix
without going through the double first ...

Titus

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com