Answered
Solution to "Subscripted assignment dimension mismatch" error
Looks like you are attempting to create a series of variable names with embedded numbers. This is usually a bad idea. Hard to co...

10 years ago | 0

| accepted

Answered
Mex Function only returns zero ... and sometimes MATLAB gives system Error.
You don't show enough code for me to determine with certainty what is going on. For instance, the following are not defined anyw...

10 years ago | 0

Answered
Changing a string in a matrix to a variable with a value given in another matrix.
Well, you can do this using the eval() function, but it is generally not a good idea to do so. You are popping these variables i...

10 years ago | 0

| accepted

Answered
continue, how to skip part of a cycle
Your if-test and continue statement are inside the inner while loop, so they apply to that loop, not the for-loop. Maybe use a b...

10 years ago | 0

| accepted

Answered
Matrix Element Transfer from one matrix to another
I am not quite clear what you are asking. Is it something like this? >> A = reshape(1:100,10,10) % <-- test data A = ...

10 years ago | 1

Answered
Matlab M-File
You should review the documentation on how to write a function, since your above code is not a correctly written function. First...

10 years ago | 1

| accepted

Answered
how to write Derivative code ?
If you can use anything except diff(), and you only want to allow simple polynomials, then use polyder() for the derivative (alo...

10 years ago | 0

Answered
Ode45 producing NaN values only
I haven't looked over your code in detail, but this definitely looks funny: for i = 1:N for j = 1:N : ...

10 years ago | 1

| accepted

Answered
Matlab Trigonometry and built in functions
You are missing the /2 inside the cosine on the lhs. E.g., >> cos((pi/5)/2)^2 ans = 0.904508497187474

10 years ago | 1

| accepted

Answered
Creating a randomly generated sentence in MATLAB
randi would be a natural choice here. E.g., for the pieces: greet{randi(numel(greet))} flatter{randi(numel(flatter))} ...

10 years ago | 1

| accepted

Answered
Would you please help me to correct this code?
Try this code (assumes spot_length is not too large): nrows = 4; % Number of rows ncols = 2; % Number of column spots ...

10 years ago | 1

Answered
naming matrix with a specific pattern
Please don't do this! It will be very hard to maintain your code. See this link for alternatives: http://www.mathworks.com/ma...

10 years ago | 2

| accepted

Answered
How can I extract a specific row of data from each column of a matrix
X_Y = X(Y + (0:numel(Y)-1)*size(X,1));

10 years ago | 0

Answered
How to not display the output of a function?
Put a semi-colon at the end of the line. E.g., x = myfunction(stuff) <-- will display the result to the screen x = myf...

10 years ago | 2

| accepted

Answered
How to speed up (or avoid) data copy from C matrix to mxArray?
No. You cannot mix C/C++ native memory with mxArray's. That will mess up the MATLAB memory manager and lead to an eventual crash...

10 years ago | 0

Answered
Splitting up a matrix - how can I do it more efficient?
This keeps the submatrices in column-order in memory as your example seems to do: Asplit = reshape(permute(reshape(A',size(...

10 years ago | 0

Answered
Variables number of for loops using recursion
Does this do what you want (assumes all of the f values are positive integers): function forloops(d,f) n = ones(1,numel(...

10 years ago | 0

Answered
I am trying to create a function form a vector from my matrix and I do not understand where my mistake is?
Here is an outline of what you need to be using for the for loops (seems to be a requirement for this assignment). % Inse...

10 years ago | 0

Answered
Array of unknown length but known upper bound: Pre-allocate then strip or build as you go?
If the memory requirement isn't too large, then just go with Option 1. That will be easy to program anyway, and will likely min...

10 years ago | 3

Answered
Converting a std::vector<float> to mxArray using ocvMxArrayFromVector
I don't know about the ocvMxArrayFromVector routine, or how to advise you to link everything in properly, but here is a short ex...

10 years ago | 2

Answered
numeric solution to matrix ODE with matrix
Generally, the only thing you need to use for this is the reshape function. It doesn't matter how "complex" your matrix stuff is...

10 years ago | 0

Answered
How can I improve speed of strcat in a for loop?
Do you need "code" inside the loop for some reason? If not, why not construct it once outside the loop? E.g., something like t...

10 years ago | 1

| accepted

Answered
fopen is not being supported in my MATLAB version. What else can I use?
Do you have the fopen function shadowed by another function or variable? What does this show: which -all fopen

10 years ago | 0

Answered
Solving an unknown with a ln
Can't you just substitute your expression and then divide by the appropriate value?

10 years ago | 1

| accepted

Answered
how to locate rows that has max values in r*2 matrix?
E.g., assuming you always want two rows (which might be the same): [~,rows] = max(x,[],1); M = x(sort(rows),:); If yo...

10 years ago | 1

| accepted

Answered
How to use Euler's method to solve the logistic grown model?
One step of Euler's Method is simply this: (value at new time) = (value at old time) + (derivative at old time) * time_step ...

10 years ago | 0

| accepted

Answered
generate sample from a normal distribution
doc mvnrnd

10 years ago | 0

| accepted

Load more