You are accessing this site in a read-only mode. For full access to all member benefits, including message posting, please login or register. Registration is completely free, simple, and takes only a few seconds.
Login |
Free MathKB.com registration |
Whole discussion thread
The message you are replying to and its parents are listed in the reverse order with the most recent posts first. This might not be the whole discussion thread. To read all the messages in this thread please click here.
Re: matlab random object
| Walter Roberson | 11 Jul 2008 19:26 |
>> and what is {:} means?
>"All elements in this dimension" Not quite.
If you have an array A, then A(:) means the same as reshape(A,[],1) -- that is, the values of A all considered together as a single column vector. This is not the same as A(1:end) or A(1:length(A)) as those forms will result in a row vector if A is not a column vector.
Similarily, if C is a multidimensional cell array, C{:} means the same as forming a comma seperated list of all the contents of the cell column array reshape(C,[],1)
The "All elements in this dimension" meaning only applies if at least two dimensions are given in the indexing. For example, A(:,:) is the same shape as A, but A(:) is always a column vector.
 Signature "The quirks and arbitrariness we observe force us to the conclusion that ours is not the only universe." -- Walter Kistler
|
| Dave Bell | 11 Jul 2008 19:05 |
> cheers for that * crying with tears*.. > > can i have a couple of basic question please? > > I've always seen these dots ... , what are these dots mean? It means the line extends, and is wrapped at that point. When you copy into the editor, you can leave out the dots AND the carriage return after them. It makes the code easier to read here, with short lines.
> and what is {:} means? "All elements in this dimension" For example,
a = [1,2; 3,4]; gives you a 2x2 array or matrix, 1 2 3 4
a(1,:) gives you the first row only, or 1, 2.
a(2,:) would give you the second row, or 3, 4.
a(:,1) gives you the first column, 1 3
a(:,2) gives you the second column, 2 4
Dave
|
| ching l | 11 Jul 2008 18:34 |
cheers for that * crying with tears*..
can i have a couple of basic question please?
I've always seen these dots ... , what are these dots mean?
and what is {:} means?
Sorry, I couldn't find them in the matlab help.
Thanks a lot.
|
| Walter Roberson | 11 Jul 2008 17:13 |
>I'm so sorry, but that's not very clear...
>I'm quite new in matlab, basically, I need to make sure the >file can be played randomly when i click the Play button in >the gui........
>possible to do that? [data, speed] = wavread(file1); samples{1} = {data, speed}; [data, speed] = wavread(file2); samples{2} = {data, speed}; [data, speed] = wavread(file3); samples{3} = {data, speed};
uicontrol('Style','pushbutton','String','Play Randomly', ... 'Units', 'normal', 'Position', [1/2 1/2 1/4 1/4], ... 'Callback', @(src, evt) wavplay(samples{ceil(length(samples)*rand)}{:}) );
 Signature "Beauty, like all other qualities presented to human experience, is relative; and the definition of it becomes unmeaning and useless in proportion to its abstractness." -- Walter Pater
|
| ching l | 11 Jul 2008 17:05 |
I'm so sorry, but that's not very clear...
I'm quite new in matlab, basically, I need to make sure the file can be played randomly when i click the Play button in the gui........
possible to do that?
|
| us | 11 Jul 2008 15:40 |
"ching l": <SNIP wants to randomize the rest of the world...
one of the solutions
% the data lst={ 'unique.m' 'whos.m' 'figure.m' }; % the engine % - randomly select a file for editing... ix=ceil(size(lst,1)*rand); edit(lst{ix});
us
|
| ching l | 11 Jul 2008 14:32 |
does rand in matlab only applicable for numbers?
What can I do if I want to randomise the files?
for examples:
wavread (file1); wavread (file2); wavread (file3);
wavplay rand(file); - the wavplay randomly choose from the wavread
is it possible to do that?
Thanks in advance.
|
Quick links:
|
|
|