Answered
why i got this error?
Make it a column vector as requested: dFdx=[F(2) ; -K1*P+F(1)*Lamda^2];

9 years ago | 0

| accepted

Answered
ode45 to Solve System of ODEs
Set up the state as a 2-element vector y. Then define the following: y(1) = coordinate location y(2) = velocity Writ...

9 years ago | 0

Answered
For stability I require that ( 2 * (1+e^(-T)) / (1-e^(-T)) ) - K > 0. How can I plot this?
Not sure what values of T you are interested in, but here is how you can plot it: K = 2; % <-- or some other value f = ...

9 years ago | 0

Answered
Index error when calculating mean of a column
You have inadvertently created a variable called "mean" in your workspace that is shadowing the MATLAB function "mean". Clear t...

9 years ago | 1

| accepted

Answered
Hello question to iterate over elements of a column
Break out of the loop when you find that first non-zero value: if zRPM(i) ~= 0 boutstart = zRPM(i); sta...

9 years ago | 0

| accepted

Answered
Why is my line not showing up on my plot?
The loop does not work because x is not a vector after the loop. You have used x as the index variable, which is a scalar. Cha...

9 years ago | 0

| accepted

Answered
Using kronecker product and elementwise multiplication
yy = repmat(y,size(der,1),1); result = bsxfun(@times,OMEGA,yy(:)); or in later versions of MATLAB result = OMEGA .*...

9 years ago | 0

| accepted

Answered
How to write a code for varying step size ?
Does this do what you want? (Using arbitrary final value of 2.000 for example) xstart = 0.000; xend = 0.500; dx = 0.01; ...

9 years ago | 0

Answered
Find the precision of a value
See this related link: <https://www.mathworks.com/matlabcentral/answers/184255-how-to-calculate-digits-after-decimal-point> ...

9 years ago | 1

Answered
Hi,I have a question about displaying perfectnumbers
You need to write the function "isperfect". MATLAB isn't finding it on your path. Also, you have a typo. That second number...

9 years ago | 0

| accepted

Answered
How do I store the individul iterations of a loop in a matrix
Index your variables: s(i) = sind(60*(i)); c(i) = cosd(60*i); Or just eliminate the loop altogether: x = (1:1:...

9 years ago | 0

| accepted

Answered
Is there a command to plot unit vectors in 3D?
E.g., point1 = [1,0,0]; point2 = [0,1,0]; point3 = [0 0 1]; origin = [0,0,0]; figure;hold on; plot3([origin(...

9 years ago | 1

| accepted

Answered
How do I store a function file to a variable?
Something like this assuming your function name is x_max my_variable = x_max(input1,input2); fprintf('The value of x_max...

9 years ago | 0

| accepted

Answered
How do you create a circle function where you can input 5 diameters and the answer would be in a 2x5 matrix showing area and circumference respectively?
Slight error in your area calculation: area = pi * (d/2).^2; If you want the function to return this as a 2x5 matrix, th...

9 years ago | 0

Answered
How do I solve a second order non linear differential equation using matlab.
Define a 2-element vector y: y(1) = z y(2) = z' then solve your 2nd order ODE for the highest derivative: z'' + ...

9 years ago | 0

Answered
mxgetpr different variable same pointer
When you do a simple assignment at the MATLAB level like this: B = A; MATLAB will create B as a shared data copy of A. ...

9 years ago | 1

Answered
User defined function to output matrix
You need to index H also in your code. E.g., if H(k) >= 1*H_max; error('H too large'); elseif H(k) >= 0.9*H_max;...

9 years ago | 0

| accepted

Answered
What is wrong with this if-elseif-else function
The main problem is this line elseif( userWeight >= 50 ) should be this instead elseif( userWeight <= 140 ) And ...

9 years ago | 1

| accepted

Answered
Writing Coefficients of a Summation?
For use with MATLAB functions like polyval and friends, the highest power coefficient is the first element on down to the consta...

9 years ago | 0

Answered
How to create a function with an algebraic input
Not really sure what you need, but here are a couple of examples: Solving with symbolic expression: >> syms x >> f = ...

9 years ago | 0

Answered
Using Recursive function to calculate all possible peptide combinations
First, for even a moderate value of n, the number of possible combinations will be *extremely* large. Generating them as a list...

9 years ago | 0

Answered
Quadratic formula using function with a single input and single output?
In your function, you could just extract the elements of coef into your a, b, and c variables if you wanted to. E.g., funct...

9 years ago | 0

| accepted

Answered
Working on if loops in class and could use help.
Consider using "nargin" <https://www.mathworks.com/help/matlab/ref/nargin.html?searchHighlight=nargin&s_tid=doc_srchtitle>

9 years ago | 0

Answered
inner matrix dimensions must agree
Probably use element-wise multiply .* instead of matrix multiply * operator Fobj = HM .* fobj; What are the sizes of HM ...

9 years ago | 0

| accepted

Answered
Undefined function or variable 'fr' and 'xm'
Your bisection method changes a0 and b0, which are then fed into your false position method as the starting point. You need to ...

9 years ago | 0

Answered
Inner matrix dimensions must agree?
Usually by changing the matrix multiply * operator to the element-wise multiply .* operator (with the period in front). Or mayb...

9 years ago | 0

Answered
Problem with a lab
The intent of the assignment is to create _vectors_ x and y, not just single values of x and y as your code is currently doing. ...

9 years ago | 0

| accepted

Answered
How to write a function that replaces every second sample of the audio by a zero value?
x = your 165040x1 vector x(2:2:end) = 0; % set each even element to 0

9 years ago | 1

Answered
Error message: In an assignment A(:) = B, the number of elements in A and B must be the same.
I would point out to you that this line will essentially clear out any current values of the psi_m variable and instead set the ...

9 years ago | 0

| accepted

Answered
How to store only 3 digits after the decimal point?
This is just a display difference. The numbers are the same. E.g., >> format long >> x = 2.123456789123456789 x = ...

9 years ago | 5

Load more