From: Oleg Komarov on
fckool <xtrangekid(a)sapo.pt> wrote in message <1706344931.315227.1276210722145.JavaMail.root(a)gallium.mathforum.org>...
> perfect, know it works.
>
> I have to explain every line of my program can you to explain this 2 lines please?:
>
> mdisplay = repmat(' ', 2^k, 2*k-1);
> mdisplay(:,1:2:2*k-1) = m;
>
> The efficient expression it's very good but I never gonna get it explains by myself lol..
>
>
> I have another question:
>
> how can I test the efficiency of my code? (how much time it need to run)
>
>
> thank you very much, and i apology if I'm being boring.

To understand the code you can highlight in the m-file the sigle parts and execute it. Another thing you can do is to place the cursor on the function and press F1 or type in the command propmt "doc repmat".

Example:
repmat(' ', 2^k, 2*k-1);
Start by higlighting "2*k-1" execute it...If k = 3 then the expression evaluates to 3.

then you can mentally rewrite the expression as:
repmat(' ',4,3) --> repeat the ' ' (blank) for 4 rows and 3 columns.

To measure the performance of your code you can read in the help about the profiler.

Oleg
From: Jos (10584) on
Walter Roberson <roberson(a)hushmail.com> wrote in message <hurmm4$32t$1(a)canopus.cc.umanitoba.ca>...
> fckool wrote:
>
> > Your code maybe not work because when you add a space (string value?) you are increasing the array dim, not?
>
> It does increase the dimensions, but that isn't necessarily a problem.
>
> > who can I separate the bits, for a better read, without increase its size?
>
> m = repmat(' ', 2^k, k);
> for i = 1 : 2^k
> m(i,:) = dec2bin(i-1,k);
> end

DEC2BIN is vectorized, so you can skip the for-loop:

k = 3 ;
m = dec2bin(0:2^k-1,k)

Jos
From: fckool on
thank you for teach me to use the help.

It was more easy try explain it than try to teach me how to use the help.

I already tried to use it..


If everybody could know everything with the help, the forum would not make sense, but ok thank you anyway.
From: fckool on
you are right, but in that way I cant have a space between each value in the array.

Thank you for the advice