Answered
I'm having trouble with the drag on my rocket projectile.
The drag force should always be in the opposite direction of current velocity direction. You don't have that. You always have d...

9 years ago | 1

| accepted

Answered
Help with a loop
Note that your if-check only runs once, so the statements n=n+1 and v=2 near the end of that block have no effect. Maybe you mea...

9 years ago | 0

Answered
Strings and numbers, strcat and num2str
Is this what you want? b = sprintf('spec-%04d-%05d-%04d',pl(j),mj(j),fb(j));

9 years ago | 1

| accepted

Answered
How can I integrate state-space equations in 6DOF with ode45?
Your derivative function f should only be returning the derivative of x, not t also. I.e., the signature of f should be somethin...

9 years ago | 0

| accepted

Answered
How to compute eccentricity for elliptical
To calculate the eccentricity of an orbit, e.g. see this link: http://space.stackexchange.com/questions/1904/how-to-programma...

9 years ago | 0

Answered
Monte Carlo simulation to find the area under the graph !!
For Monte Carlo, simply define a rectangle that encompasses your function between the specified limits. Then generate uniform ra...

9 years ago | 0

Answered
Adding two polynomial(anonymous)
E.g., using your original "a" and "b" functions, simply: syms x a(x) + b(x)

9 years ago | 1

| accepted

Answered
plotting an implicitly defined function in 3 dimensions
Something like this? t = linspace( -100, 100, 50 ); [x y] = meshgrid(t); surf(x,y,4-x-y)

9 years ago | 0

| accepted

Answered
How to create a 3 dimensional matrix from two matrices each of 2 dimensions
C = reshape([A;B],size(A,1),2,size(A,2));

9 years ago | 0

Answered
Plotting an Anonymous Function
You need to explicitly give plot the "x" information, not just the "y" information. E.g., x = -5:5; plot(x,sqr(x))

9 years ago | 1

| accepted

Answered
MEX Fortran code crashes Matlab
I haven't had time to look this over in any detail yet, but the first thing you should do is replace those STOP statements. E.g....

9 years ago | 0

| accepted

Answered
How to have presistent physical constants?
If you want to do it the way pi is done, then create your own function files. E.g., % File ec.m on the path function res...

9 years ago | 1

| accepted

Answered
Mex mxCreateStructMatrix and mxSetFieldByNumber massive Matlab workspace byte use.
I will look at this some more tomorrow, but first, this line creates a permanent memory leak: mxSetData(field_value, copy...

9 years ago | 3

| accepted

Answered
Runge-Kutta 4th Order
OK, I will offer a bit more help here (well, actually a lot more help). Your most immediate problem is that you are treating you...

9 years ago | 3

Answered
Compute the velocity of a free-falling parachutist using Euler's method for the case where m = 80 kg and cd=0.25 kg/mPerform the calculation from t = 0 to 20 s with a step size of 1 s.
Here is an outline to get you started: ---> constant stuff goes here <--- t = 0:1:20; % The time values (s) n = num...

9 years ago | 0

Answered
How can I solve the max iterations exceeded?
Had to hunt for awhile to find a place where the function switches signs, but try this for a starting point: r = 0.1e-9

9 years ago | 0

| accepted

Answered
How to remove second digit of first a column
To retain the 1st digit for the numbers shown: result = [floor(A(:,1)/10) A(:,2)]; To retain the 2nd digit for the numbe...

9 years ago | 1

Answered
When I use ^ to square a value or a vector, it gives me Error: The input character is not valid in MATLAB statements or expressions. how I can fix this problem?
Two issues. First, using the = with nothing on the left hand side will generate the error you are getting because there is nothi...

9 years ago | 0

| accepted

Answered
Multiply each row of a matrix by a matrix
c = sum(bsxfun(@times,B',A*B')); or another way, but does a lot of extra work for the off-diagonals that are discarded: ...

9 years ago | 1

Answered
How to rearrange rows in matrix of a matlab ?
M = your matrix [~,x] = sort(sum(M,2)); result = M(x,:);

9 years ago | 1

| accepted

Answered
Could i use MatLab to "find x given y"?
Solving manually, t = log((y - 930)/1000)/(-0.05) or symbolically, >> syms t y >> solve(1000*exp(-0.05*t)+930-...

9 years ago | 0

| accepted

Answered
how to feed one string to array on NaN?
No, you can't combine character strings as elements of a numeric array like that. To combine different data types in one variabl...

9 years ago | 1

Answered
how to multiply cell with a vector such that cell contains a matrix and each row is multiplied by different element of vector?
It is not clear to me what you want to have happen to rows 3-5. Assuming it is similar to the other rows, does this do what you ...

9 years ago | 0

| accepted

Answered
how to construct 4x2 matrix taking value 0 and 1 randomly? No rows should be repeated.
result = dec2bin(randperm(4)-1) - '0';

9 years ago | 0

Answered
How to find arrays in a cell array
c = your cell array x = cellfun(@(x)size(x,1)<5,c); % Logical indexes of arrays with 1st dim < 5 c(x) = []; % Delete t...

9 years ago | 1

| accepted

Answered
Function "fix" with numbers/characters
When you invoke a function without using the parentheses, MATLAB regards all of the inputs as strings. This is true for any func...

9 years ago | 0

Answered
error in solving cell array multiplication
result = cellfun(@(X)bsxfun(@times,Daily_demand(:),X),all_comb_of_routes,'uni',false); btw, you can replace this code: ...

9 years ago | 0

| accepted

Answered
mxCreateStructArray and mxCreateStructMatrix field name memory management
_"Are the field name character arrays copied before being stored internally?"_ Yes. Internally in the mxArray, the field name...

9 years ago | 1

| accepted

Answered
matrix rows combination with all possibilities
E.g., one way to generate the possible combinations all in one 3D matrix, where each 2D plane (the first two dimensions) have th...

9 years ago | 3

| accepted

Answered
difference between | and || in my function
The "|" operator is an element-wise operator, intended to be used on arrays element-by-element. The "||" operator is a short-ci...

9 years ago | 0

| accepted

Load more