From: Chiemera on
On 31 Temmuz, 21:26, "Matt Fig" <spama...(a)yahoo.com> wrote:
> The problem is that each element of a row vector may contain any number of digits, but each element of a numerical character array is ONE digit (or space).  Look:
>
> A = [10 20 30 40 5000];
> B = num2str(A);
> whos B A  % Notice the lengths
>
> Now you could turn to cell arrays to get what you want:
>
> B = cellfun(@(x) sprintf('%d',x),num2cell(A),'Un',0);  % See help for sprintf
>
> Now each element of the cell array B is a string.  For example,
>
> ischar(B{1})  % YES.
>
> and
>
> whos A B  % But look at the class!

Thanks! This is what I want :) But I've a new problem :(

dslb=num2str(labelsTR);
dslb = cellfun(@(x) sprintf('%d',x),num2cell(labelsTR),'Un',0);
samplesDS=dataset(samplesTR,dslb); % Dataset command only accepts
string labels.
samplesTR=pca(samplesDS,0.98); % Here, pca is for principal
component analysis in PRTools.

>>whos samplesTR labelsTR
Name Size Bytes Class Attributes
labelsTR 1x1458 11664 double
samplesTR 160x1458 1866240 double

I want to use samplesTR and labelsTR together for input of SVM. Bu
I've taken this error:"Numbers of objects and labels do not match".
But both has same size. Where is the problem? Do you have any idea?
Regards..
From: Matt J on
Chiemera <muratgok(a)gmail.com> wrote in message <f2607541-3e08-4150-8dcd-c707275f8746(a)f33g2000yqe.googlegroups.com>...

> But both has same size. Where is the problem? Do you have any idea?
================

Nope. But the error messages should tell you "where" the problem occured.
From: Matt Fig on
Chiemera <muratgok(a)gmail.com> wrote in message <f2607541-3e08-4150-8dcd-
> Thanks! This is what I want :) But I've a new problem :(
>
> dslb=num2str(labelsTR);
> dslb = cellfun(@(x) sprintf('%d',x),num2cell(labelsTR),'Un',0);
> samplesDS=dataset(samplesTR,dslb); % Dataset command only accepts
> string labels.
> samplesTR=pca(samplesDS,0.98); % Here, pca is for principal
> component analysis in PRTools.
>
> >>whos samplesTR labelsTR
> Name Size Bytes Class Attributes
> labelsTR 1x1458 11664 double
> samplesTR 160x1458 1866240 double
>
> I want to use samplesTR and labelsTR together for input of SVM. Bu
> I've taken this error:"Numbers of objects and labels do not match".
> But both has same size. Where is the problem? Do you have any idea?
> Regards..

You are not trying very hard to help us help you. If you have an error, usually the error message will tell you which line the error was on. That is, the message will explicitly tell you which function call, for example, errored. I am going to *guess* that the error is in the call to the DATASET function, which takes, as can be seen by reading the documentation, arguments like this:

dataset(VAR1,VAR2,{VAR,name_1,...,name_m})

Is that the case? Did you read all of the help for the DATASET function, if indeed that is where the error is occurring? Because from your previous posts it looks like even after you figure out how to pass multiple variables, you are going to have a problem with invalid MATLAB variable names, such as this assignment:

15 = 6. % '15' is a string name (your OP) and 6 is the variable.

I don't have the DATASET function, so this is only a guess based on what sparse information you have provided and what I can read from the online doc.