I have created a variable A = zeros(5,5). The first three columns contain double values. I have another variable which contains strings for example 'Yes' or 'No'. I am trying to add this variable to A(:,4) (to make it as the fourth column) but I keep getting an error which says " The following error occurred converting from cell to double:
Error using ==> double
Conversion to double from cell is not possible."
I am not sure what I am doing wrong. It should be quite straight forward. Can someone help?
"Raju Gain" <supernova5271@yahoo.com> wrote in message <garivv$sni$1@fred.mathworks.com>...
> Hello,
>
> I have created a variable A = zeros(5,5). The first three columns contain double values. I have another variable which contains strings for example 'Yes' or 'No'. I am trying to add this variable to A(:,4) (to make it as the fourth column) but I keep getting an error which says " The following error occurred converting from cell to double:
> Error using ==> double
> Conversion to double from cell is not possible."
>
> I am not sure what I am doing wrong. It should be quite straight forward. Can someone help?
>
> Thanks
Search the documentation for information on creating a cell array. This will hold both numerical and text data.
Barry
"Raju Gain" <supernova5271@yahoo.com> wrote in message <garivv$sni$1@fred.mathworks.com>...
> Hello,
>
> I have created a variable A = zeros(5,5). The first three columns contain double values. I have another variable which contains strings for example 'Yes' or 'No'. I am trying to add this variable to A(:,4) (to make it as the fourth column) but I keep getting an error which says " The following error occurred converting from cell to double:
> Error using ==> double
> Conversion to double from cell is not possible."
>
> I am not sure what I am doing wrong. It should be quite straight forward. Can someone help?
>
> Thanks
"Raju Gain" <supernova5271@yahoo.com> wrote in message <garivv$sni$1@fred.mathworks.com>...
> I have created a variable A = zeros(5,5). The first three
> columns contain double values. I have another variable
> which contains strings for example 'Yes' or 'No'. I am
> trying to add this variable to A(:,4)
You cannot mix data classes in a single array. You cannot
have text in a numeric array.
The closest you can get is the approach the other poster
suggested, which is to use a cell array -- or you could
use a structure which had a field for the numerics and
another field for the text. But neither cell arrays
nor structures will display "nicely" as columns of numbers
intermixed with columns of text.
"Walter Roberson" <roberson@ibd.nrc-cnrc.gc.ca> wrote in message <garkd2$ifv$1@fred.mathworks.com>...
> "Raju Gain" <supernova5271@yahoo.com> wrote in message <garivv$sni$1@fred.mathworks.com>...
>
> > I have created a variable A = zeros(5,5). The first three
> > columns contain double values. I have another variable
> > which contains strings for example 'Yes' or 'No'. I am
> > trying to add this variable to A(:,4)
>
> You cannot mix data classes in a single array. You cannot
> have text in a numeric array.
>
> The closest you can get is the approach the other poster
> suggested, which is to use a cell array -- or you could
> use a structure which had a field for the numerics and
> another field for the text. But neither cell arrays
> nor structures will display "nicely" as columns of numbers
> intermixed with columns of text.
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.
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central.
Read the complete Terms prior to use.