Respondida
Write a script.Create a vector of five random integers, each in the range from -10 to 10.Perform each of the following:•Subtract 3 from each element•Count how many are positive•Get the minimum
To create a script file, do the following at the command prompt: edit my_script_name.m The editor should open up a file ...

más de 9 años hace | 0

Respondida
How can I save only content of matlab figure ?
You might check out this FEX submission by Yair Altman: http://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig ...

más de 9 años hace | 0

Respondida
Finding if a random walk "hits" a target in two dimensions
For 2D I assume you have x and y vectors that you are building at each step, and that Target is a 2-element vector with an x and...

más de 9 años hace | 0

| aceptada

Respondida
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...

más de 9 años hace | 1

| aceptada

Respondida
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...

más de 9 años hace | 0

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

más de 9 años hace | 1

| aceptada

Respondida
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...

más de 9 años hace | 0

| aceptada

Respondida
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...

más de 9 años hace | 0

Respondida
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...

más de 9 años hace | 0

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

más de 9 años hace | 1

| aceptada

Respondida
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)

más de 9 años hace | 0

| aceptada

Respondida
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));

más de 9 años hace | 0

Respondida
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))

más de 9 años hace | 1

| aceptada

Respondida
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....

más de 9 años hace | 0

| aceptada

Respondida
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...

más de 9 años hace | 1

| aceptada

Respondida
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...

más de 9 años hace | 3

| aceptada

Respondida
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...

más de 9 años hace | 3

Respondida
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...

más de 9 años hace | 0

Respondida
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

más de 9 años hace | 0

| aceptada

Respondida
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...

más de 9 años hace | 1

Respondida
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...

más de 9 años hace | 0

| aceptada

Respondida
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: ...

más de 9 años hace | 1

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

más de 9 años hace | 1

| aceptada

Respondida
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-...

más de 9 años hace | 0

| aceptada

Respondida
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...

más de 9 años hace | 1

Respondida
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 ...

más de 9 años hace | 0

| aceptada

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

más de 9 años hace | 0

Respondida
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...

más de 9 años hace | 1

| aceptada

Respondida
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...

más de 9 años hace | 0

Respondida
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: ...

más de 9 años hace | 0

| aceptada

Cargar más