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

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 0

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

casi 9 años hace | 1

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

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 1

| aceptada

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

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 0

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

casi 9 años hace | 0

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

casi 9 años hace | 1

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

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 1

| aceptada

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

casi 9 años hace | 0

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

casi 9 años hace | 0

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

casi 9 años hace | 0

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

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 0

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

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 0

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

casi 9 años hace | 0

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

casi 9 años hace | 0

| aceptada

Respondida
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

casi 9 años hace | 1

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

casi 9 años hace | 0

| aceptada

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

casi 9 años hace | 5

Respondida
Rename function inside MATLAB script
One way assuming your input is a string: FunctionName = 'newName'; : FunctionHandle = str2func(FunctionName); ...

casi 9 años hace | 1

| aceptada

Respondida
Variable Usage in Function File
1) Return vel as an output of your function. E.g., function [vel,vend] = velocity1(dt, ti,tf,vi) 2) Have your driver co...

casi 9 años hace | 0

| aceptada

Respondida
Unexpected MATLAB operator when trying to a run a script from the command line
Make the input a character string by using quotes: run('/gs/gsfs0/users/mvolaski/test.m')

casi 9 años hace | 1

| aceptada

Respondida
What does the tilde (~) in the following code mean?
It's syntax that means to ignore the input argument, if there is one. That is, you can call the function with no input argument...

casi 9 años hace | 3

| aceptada

Cargar más