|
|
Hi ysjung,
for some functions (including length), you can use cellfun:
num = cellfun('length',strvec)
Titus
"ysjung" <yusjungcu@xxxxxxxxx> schrieb im Newsbeitrag
news:ef16bda.-1@xxxxxxxxxxxxxxxxxxx
> Is there way I can vectoize for loop below? I noticed in cell array
> you are limited when it comes to characters.
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> strvec = {'Set' 'ASCIIIIIIII' 'textas' 'yuioop'};
>
> for i = 1:length(strvec),
> num(i) = length(char(strvec(i)))
> end
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> I am kinda looking for length of each character on this array, strvec
> = [3 11 6 6];
>
> the above code does the job, but just want to find out if there is
> simpler way.
|
|