Answered
mexPrintf to standard error
Brute force? I can't think of another way to get at the MATLAB standard error printing. E.g., /* Includes ---------------...

9 years ago | 0

| accepted

Answered
Making a matrix using colons or linspace working improperly within code
I suspect this is being caused by floating point round off error in the various calculations. Maybe just use a round in your lin...

9 years ago | 0

| accepted

Answered
find closest pairs in two datetime arrays with unequal length
Are the arrays sorted? Using sorted arrays, one could come up with a stepping algorithm. E.g., if you know that t2(k) < t1(i) ...

9 years ago | 0

Answered
Taylor and Euler Method for ODE
MATLAB is a 0-based indexing language. So you can't have y(0) in your code. It will need to start at y(1). y(1)= -0.25; ...

9 years ago | 0

| accepted

Answered
Coversion of visual c to matlab line
Rather than converting the code, you might consider a mex solution: https://www.mathworks.com/help/matlab/programming-interfa...

9 years ago | 0

Answered
How to pass parameters?
Not sure if this is what you want, but just pass them in: dX = -13.925*A*B*C*x + f(t,A,B,C); : function fval =...

9 years ago | 1

| accepted

Answered
Trying to graph each iteration of the for loop
You are plotting p(1,:) in the loop, but this never changes in the loop. Did you mean to plot pdot instead? E.g., plot(t,pd...

9 years ago | 0

Answered
4-D array to 3-D array
E.g., x = your 304 * 448 * 37 * 12 array y = reshape(x,304,448,37*12); Another possibility if you want those last two...

9 years ago | 0

| accepted

Answered
Error with matrix dimensions depending on which version of matlab i use.
Guessing that your friends are running R2016b and you are running an earlier version. In R2016b dimension mismatches such as thi...

9 years ago | 2

| accepted

Answered
Problem converting cell to string
If the individual cells can have more than two elements, e.g., U={[1,4],[1,5],[1,6],[2,4],[2,5],[2,6],[3,4,5],[3,5],[3,6,9]...

9 years ago | 0

Answered
Create a new field in a structure
Not sure if this is what you are really asking: mystruct.field1 = rand(1,3); % <-- Create a structure with field named fie...

9 years ago | 0

Answered
Weird!!!! Extremely simple question!! Can't assign values to first row of a sparse matrix, please help.
Typo. You used a small case 's' in that first row assignment. Change that to an upper case 'S' and everything will be as expecte...

9 years ago | 1

| accepted

Answered
A Few Key Concepts to Take From One Complete Program and Apply to Another Very Similar Second Computer Program from an Exponential Distribution with Lambda Function Applied..
I _*think*_ your question is how to generate exponential(lambda) random numbers. If so, you can get them from uniform(0,1) numbe...

9 years ago | 0

| accepted

Answered
How do I isolate a letter in some equation?
symvar is probably what you are looking for. E.g., >> eqn = '2=2*log(x).^2'; >> symvar(eqn) ans = 'x' EDIT...

9 years ago | 1

| accepted

Answered
How to limit user input to only one character?
Maybe this FEX submission by Jos is close to what you want: http://www.mathworks.com/matlabcentral/fileexchange/7465-getkey ...

9 years ago | 0

Answered
Matrix indexing multiple rows
x = your matrix result = x([2:4,5:8],:); % <-- pick off rows 2-4 and 5-8 Of course, the 2:4 and 5:8 could have been com...

9 years ago | 5

Answered
I need to compare two large arrays of data. Running is too slow, it takes 5 days to run the script below. Is it possible to run the script in less time? As?
Not a complete solution, but for starters I would suggest the following: Pull all of the data copying you do that does not de...

9 years ago | 0

Answered
How to repeat a for loop n times
Is this all you are trying to do? n = number of times to repeat the loop States = zeros(size(N,1)); for k=1:n ...

9 years ago | 0

| accepted

Answered
i want to make a for loop that goes like this for a=0:1:180 && 179:-1:-180 but it is not possible in matlab, any ideas how to do it?
It is not clear to me what you really want. Maybe this? for a=[0:1:180,179:-1:-180] % whatever end

9 years ago | 0

| accepted

Answered
need a help using loop
You have learned the hard way one of the first lessons of good programming practice ... don't create a bunch of variables with t...

9 years ago | 0

| accepted

Answered
How to confirm user input is a word based on ascii table?
Like this? prompt = 'Enter word '; while( true ) answer = input(prompt, 's'); if( all(ismember(answer,'AB...

9 years ago | 0

Answered
Question about machine epsilon
The short answer is that the result is rounded. How this rounding takes place is going to depend on the rounding modes available...

9 years ago | 2

| accepted

Answered
Improve efficiency of backslash operator for sparse matrices
You might find something in Tim Davis FEX submissions that would help: http://www.mathworks.com/matlabcentral/fileexchange/?t...

9 years ago | 0

Answered
matlab code to make values of an array in specific ranges(index positions) equal to zero
for k=1:numel(start_index_positions) d(start_index_positions(k):end_index_positions(k)) = 0; end

9 years ago | 0

Answered
mxSetData to subset of mxArray
Not without a hack. The reason is as follows: The API functions mxSetPr, mxSetPi, mxSetData, mxSetImagData, mxSetIr, and mxS...

9 years ago | 1

| accepted

Answered
Why use ./ in x = ( (-1).^(n+1) ) ./ (2*n - 1)
Yes, you need to use .^ and ./ instead of ^ and / because at least one of the operands is not a scalar. If at least one of the ...

9 years ago | 1

| accepted

Answered
mxAddField/mxGetField with unicode name
_... Is it possible to work with structures using 2-byte wide characters? ..."_ If I understand your question, the answer is ...

9 years ago | 1

| accepted

Answered
Is there any way to speed up matrix multiplication if I only need a subset of the entries?
Just out of curiosity I coded up a mex routine to compare. The mex routine simply does naive dot products between rows & columns...

9 years ago | 1

Answered
Newton Raphon's Method - Help
I don't know why you would use all of the symbolic stuff inside your function (as opposed to just hard coding the derivative), b...

9 years ago | 1

Answered
Bisection Method Not Working
It is not clear to me that your initial guesses are even bracketing your desired tof. So there will be no hope that your bisecti...

9 years ago | 0

Load more