Answered
compute force matrix from positions matrix
There surely is way to vectorise your code, using bsxfun, accumarray and/or arrayfun, for instance. However, this most likely t...

10 years ago | 0

Answered
i have a code which is written in 2006.the author's name is Xiang Bai .code dose not run. i cant find the problem. so i attached the code and the error message.can anyone help me? i really need help.
This errors arise when the classes of two variables differ. a = uint32(4) b = int8(4) a-b You can try to cast the ...

10 years ago | 0

Answered
Please help! Combine figures into one new figure
Take a look at copyobj figure(1) subplot(1,2,1) ; ph{1} = plot(cumsum(rand(10,20)),'bo') ; figure(2) ax = subp...

10 years ago | 1

Answered
Plot 10 times and take the average
users = [10 20 30 40 50]; N = numel(users) ; rates = zeros(1,N) ; % pre_allocation for i = 1 : N tempV = My...

10 years ago | 0

Answered
Do you have a suggestion for a name of my function?
Thanks all! Nice to see, you all agree that RUN (or boat) should be part of the function name. I'll use runindex as the function...

10 years ago | 0

Answered
array length is not what I've set...
In your code, the variable *j* has two roles: # an index into Hopt # a value that is used for calculation (angle?) Your b...

10 years ago | 1

Answered
Do you have a suggestion for a name of my function?
Thanks for the inspiration! What about *runindex*? Or is this confusing with regard to existing functions?

10 years ago | 1

Answered
what is the fastest way to convert a cell array of delimited numbers into a matrix
A = {'1,5012,0,35,6' ; '2,395,1,35,8'} ; A = repmat(A,250000,1) ; % big array! tic ; A2 = strcat(A,',') ; V = ssca...

10 years ago | 4

Question


Do you have a suggestion for a name of my function?
I have written a nice little function which I would like to put on the File Exchange. However, I am still looking for a short an...

10 years ago | 6 answers | 2

6

answers

Answered
How do I rename fields of a structure array?
You can use DEAL and a for-loop to change fieldnames: % create a structure array, with different fields for k=1:10, ...

10 years ago | 1

Answered
How do I rename fields of a structure array?
There is a somewhat hidden function called *renameStructField*, that can do the job, perhaps within a loop. Or use dynamic fi...

10 years ago | 2

Answered
how to create random numbers according to any distribution within a range
First, carefully read the help of RAND, especially the first example in it. The next step is to define your distribution more...

10 years ago | 0

Answered
I want to find the non-zero numbers in each row
help find

10 years ago | 0

Answered
Operands to the && operators must be convertible to logical scalar values.
Perhaps this example can help you in how to use logical operators with vectors: x = randn(1,20) y = randn(1,20) t...

10 years ago | 0

Answered
Any simple way to change a struct with fields of length "n" to a struct of length"n"?
This question clearly shows how _not_ thinking about your data management in the beginning will get you into trouble later on. ...

10 years ago | 2

Answered
How to delete the colon's in a matrix?
Is the data stored as strings in a cell array? C = {'1,6:3','2,5:3','99,103:4'} C2 = strrep(C,':',',')

10 years ago | 0

Answered
How to generate a matrix of all permutations of numbers ignoring repeats
Does this produce your result? Note that the matrices become too large very rapidly ... My function PERMPOS can be download...

10 years ago | 0

Answered
I want to plot some thing like this picture how can i do this ?
Use *AXES* to create a new axis relative to the another axes x = 0:100 ; y = exp((x/50).^2)+rand(size(x)) ; % some data ...

10 years ago | 1

| accepted

Answered
Find exact time step
Let S be your vector of speeds, and T your time points % Determine, for each time point, is the subject running or not ...

10 years ago | 1

Answered
problem with input names of vectors loaded in a function
Do not store your data like this. It is the contents of a variable that should change, not the name itself. In your case, you...

10 years ago | 0

Answered
GUI Question: Have a pop-up dialog which has license agreement? Accept/Decline pushbuttons.
Sure! You can, for instance, use *QUESTDLG* for this: function Main disp('Welcome to this function.') ; ButtonNam...

10 years ago | 0

Answered
How to change plotyn plot curve lines to stairs line
Can't you use *STAIRS*? An example: x = 0:.2:pi/2 ; y = sin(x) ; plot(x,y,'bo-') ; hold on ; stairs(x,y,'r.-') ...

10 years ago | 1

| accepted

Answered
Replace elements of sparse matrix from a full matrix.
What don't you replace the elements before converting it?

10 years ago | 0

Answered
How can I get the Mastering Matlab Toolbox
Duane Hanselman retracted all the files from the Matlab File Exchange, but the book has its own website where you can download t...

10 years ago | 1

| accepted

Answered
The value of each iteration is not recorded in cell
You want to loop over several elements: *for k = 1:11* rather than *for k = 11*

10 years ago | 0

| accepted

Answered
How to generate 500 permutations of any vector length 20? I am getting error
To generate one permutation of y you can use randperm Y = [45 45 45 45 45 45 0 0 30 30 0 0 0 0 45 45 45 45 45 45]; R = r...

10 years ago | 0

| accepted

Answered
How do I avoid using for loop when I want to treat the rows of a matrix individually?
This will work for unique rows of A: B=[1 2 1 3;1 2 1 4;1 3 1 4;1 2 1 6;1 4 1 5;1 5 1 3;1 5 1 7]; A=[1 2;1 5]; D=[1 3...

10 years ago | 0

Answered
How to restrict the range ?
I do not see why you need bsxfun for this. If X is your signal, this statement restricts X between -1 and 1 X = [0.5 1 2 -2...

10 years ago | 0

| accepted

Answered
How to extract a row of 2D cell array and store it in another 1D cell array?
As for any 2D array, each row of a 2D cell array has to have the same number of elements. I assume you meant to say that *each c...

10 years ago | 1

Load more