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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

8 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

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

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

8 years ago | 5

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

8 years ago | 1

| accepted

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

8 years ago | 0

| accepted

Answered
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')

8 years ago | 1

| accepted

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

8 years ago | 3

| accepted

Answered
How do I solve system of matrices with a for loop and save each iteration in an array?
You just need to rearrange your code a bit. Currently you are overwriting stuff. Endpoint_forces = NaN(2,101); for i = ...

8 years ago | 0

Load more