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

Answered
Create a vector to prove a sum of series?
Sounds like homework, but I will give you some hints: v = 1:n; % <-- make a vector with the numbers 1, 2, 3, ..., n 1 ./ ...

10 years ago | 0

| accepted

Answered
How to create a matrix with specified numbers in random positions?
m = desired row size n = desired column size f = fraction of 1's to place randomly in result result = zeros(m,n); % p...

10 years ago | 0

| accepted

Answered
How I can solve this equation?
e^(whatever) is coded in MATLAB with the exp() function. E.g., exp(-t/trb)

10 years ago | 2

| accepted

Answered
I am trying to in inverse of a 3x3 symbolic matrix and i keep getting FAIL. it works fine with a 2x2 but how do i get the inverse of a symbolic 3x3 matrix
The rows are dependent, so the matrix is singular, hence the FAIL. row1 + row2 = -row3 I.e., det(A) = 0

10 years ago | 0

Answered
How to use GPU to define a large 3D matrix
For starters, put semi-colons at the end of the delta(etc) = etc lines so that intermediate stuff doesn't print to the screen. D...

10 years ago | 0

| accepted

Answered
how to display in one variable the max of each one of two arrays?
c = [max(a) max(b)];

10 years ago | 1

| accepted

Answered
why - if kk = num (where kk = 6.0000 and num = 6 ) gives me false
The number is close to, but not exactly 6. When a value is exactly 6, MATLAB will display the value without any trailing 0's aft...

10 years ago | 2

| accepted

Load more