Answered
ODE function does not seem to work
You need to make a few adjustments in your code. This: k=3; c=1; m=3; sdof = @(t,x) [0 1;-k/m -c/m]*x(:); t0=0; tf=20; ...

8 years ago | 0

| accepted

Answered
I keep getting an error message on this code, I dont know what the problem is. Keeps saying the expression is invalid
You need to: Put parentheses around the ‘t’ after the ‘@’ operator; use element-wise operations in your ‘v1’ anonymous functio...

8 years ago | 1

| accepted

Answered
Displaying multiple Outputs?
With all the argument variables present in your workspace, call it in a script as: [YPV,YPDV,YPR,YPDR,NPV,NPDV,NPR,NPDR] = tur...

8 years ago | 0

| accepted

Answered
how to generate curve up to particular point?
Referring back to your previous Question (and thank you for Accepting it): syms Rb R1=200; R3=100; R2=(R1+R3)/2; theta=135...

8 years ago | 0

Answered
Weighted lsqcurvefit, applying weight to the start of curve
One option would be to create a weighting vector defined for example as: Wgt = 1./(xdata + q); where ‘q’ is defined as some c...

8 years ago | 2

| accepted

Answered
unweighted least square estimation with fminsearch
You should be summing the squares, not squaring the sum. Try this: fun = @(P)sum((f1 - (a_offnadirangel .* P(1).^(( 1 + erf...

8 years ago | 1

Answered
xlsread error, wont open file
A guess: A1 = xlsread(fullpath,1,'A2:A16'); B1 = xlsread(fullpath,1,'B2:B16')*1E-3;

8 years ago | 0

Answered
How to include different values for x-ticks
Try this: x=[2 5 3 7 10]; y=[10 13 15 7 3]; yrs = 2000:2004; t = datenum([yrs' zeros(numel(yrs),4) ones(size(yrs'))]); f...

8 years ago | 1

Answered
How can I fill in an area between a curve that is nonlinear?
This was something of a challenge because ‘t’ is not uniformly finite. Nevertheless, a bit ot creative logical indexing works, ...

8 years ago | 1

| accepted

Answered
Error using integral2
This works, although it throws a warning: Ntrunc = 100; L = 100; % Length of the box p=1; q=1; Ui = @(x,y) sin(pi*x).*sin...

8 years ago | 1

| accepted

Answered
how to caculated matrix
The only way I can make that work: C = rem(abs(A - abs(B)),36)

8 years ago | 0

Answered
How can I fit an exponential curve?
Try this: filename1 = 'x2.mat'; D1 = load(filename1); x = D1.x2; filename2 = 'y2.mat'; D2 = load(filename2); y = D2.y2; ...

8 years ago | 0

| accepted

Answered
Matlab now allows inconsistent matrix dimensions to be added and its a problem. How do I turn this off?
This is called ‘implicit expansion’. It was introduced in R2016b (if I remember correctly). You cannot turn it off.

8 years ago | 1

Answered
how to estimate cdf from ksdensity pdf
There is an option for ksdensity to return the cdf: x = [randn(30,1); 5+randn(30,1)]; [f,xi] = ksdensity(x); figure plo...

8 years ago | 1

Answered
Why does the loop not work for the increment stated?
Your code is essentially correct. If you want all the itermediate results, you need to index ‘v’: for t= 0:1:20 a= [t, sin...

8 years ago | 0

| accepted

Answered
I am trying to find a variable which appears in the workspace and is used as an input to a function in the code. How can I find how and where is it defined?
If you are using the MATLAB Editor, in the ‘NAVIGATE’ tab in the top toolstrip, click on ‘Find’. Go to the beginning of your sc...

8 years ago | 0

Answered
Running csv file through if else statement
First, if you are comparing vectors,use one ‘&’, not ‘&&’. Second, again if you are comparing vectors, you will likely need t...

8 years ago | 0

Answered
How to Plot FFT for Matlab?
The result of the Fourier transform will be complex. Use the abs() (absolute value) function to recover the amplitude from the ...

8 years ago | 0

Answered
Numerically solving x + Asin(Wx+C) = 0, for x. (A, W & C are known constants)
I am not certain what you are doing. I would use fzero or fsolve.

8 years ago | 1

Answered
How to Design a Band-Pass Filter
Try this: EMG = rand(1,1E+4); % EMG Signal N = length(EMG); Fs = 200; ...

8 years ago | 0

Answered
How to calculate the derivative of any function f(x) at x=0 using finite difference method?
if ‘a,b,c’ are numerical values and not functrions of ‘x’, the derivative would be uniformly 0.

8 years ago | 1

| accepted

Answered
atand and atan2d
I am not certain what result you want. Try these utility functions I created for my own use a while ago: Angles360 = @(a) r...

8 years ago | 0

| accepted

Answered
what bsxfun will perform here?
The bsxfun call calculates a vector of logical elements. If ‘C’ is greater than ‘K*U’, the output is true, and the expression...

8 years ago | 0

| accepted

Answered
how can I count occurrence of pattern in a sequence
One option: Bases = 'ATGTGTC'; Seq = 'TGT'; Rpts = strfind(Bases,Seq); Out = numel(Rpts) producing: Out = 2

8 years ago | 0

| accepted

Answered
How can I reduce error on loglog scale using linear regression?
Change them to additive errors (as they should be) using nonlinear regerssion techniques. Example (from another Answer) — ...

8 years ago | 1

| accepted

Answered
How to store my data
Since we do not have your ‘ojaData-2.mat’ file, the only recommendation I have is to save ‘trajectory’ as a cell array: trajec...

8 years ago | 0

| accepted

Answered
how to perform a polyfit on semilog plot?
Try this: FOE=[0.000743 0.000747 0.000747 0.000746 0.000746 0.000744 0.000744 0.000743 0.00065 0.00065... 0.000648 ...

8 years ago | 2

| accepted

Answered
How to plot the frequency response of a fir filter when I only have the filter co-efficients?
Use the <https://www.mathworks.com/help/signal/ref/freqz.html *|freqz|*> (link) function to plot the Bode plot. Since your ...

8 years ago | 1

Answered
How to use polyfit function
Without your file, it is difficult to provide specific code. However, these lines: x=strain==linspace(0,.27); y=st...

8 years ago | 0

Answered
Detecting fundamental frequency of a signal using Fast Fourier transform
You have not actually described the problem you are having. If your audio signal consists of _different_ notes, the <https:...

8 years ago | 0

Load more