Answered
sprintf conflict in operations
To use ‘Pmax’ in a calculation, it has to be turned back into a number. Try this: Mt2b=sprintf('%.0f\n',((pi^2)/8)*0.2*str2...

5 years ago | 1

| accepted

Answered
NaN values in timetable - how to calculate Nash–Sutcliffe model efficiency coefficient?
If the ‘missing’ data are NaN entries, this works: data = rand(10,3); % Create Array data(ra...

5 years ago | 1

| accepted

Answered
curve fit on two Y variables with unequal X?
To clarify, the lengths of the ‘X1’ and ‘Y1’ data set are the same as each other, and the lengths of the ‘X2’ and ‘Y2’ data set...

5 years ago | 2

Answered
drawing two spheres with a rod connecting them.
Experiment with this: [Xs, Ys, Zs] = sphere(20); [Xc, Yc, Zc] = cylinder(0.5); figure S1 = surf(Xs, Ys, Zs); hold on s2...

5 years ago | 0

Answered
to find fourier transform of e^-t u(t). How do i remove this error
The fourier function does not allow limits, so that integration would need to be done manually: syms t omega y = int(exp(-t)...

5 years ago | 0

Answered
Extract and save specific values from a fitted curve
I am not exactly certain what you want. Try this: x = linspace(0, 10); y(1,:) = x.*exp(-0.75*x); y(2,:) = x.*exp(-0.95*x)...

5 years ago | 1

Answered
How Define Delta Function
If you have the Symbolic Math Toolbox, use the dirac function. It can be used with non-symbolic arguments as well.

5 years ago | 2

| accepted

Answered
Looking for an alternative to regexp.
See if adding either: Out = cell2mat([nodes{:}].') or: Out = str2num(cell2mat([nodes{:}].')) to the posted code provides t...

5 years ago | 0

Answered
How to plot a decresing part of a function
It depends on how you want to plot it. The slope is and the line you want to plot intersects the -axis at . The linear slo...

5 years ago | 0

Answered
solve x as function of y
Try this: Po2a1 = linspace(0, 150); So21= 100* ((-8.5322289*10^3.*Po2a1) + (2.1214010*10^3.*(Po2a1.^2)) + (-6.7073989*10^1.*(...

5 years ago | 0

Answered
How to compute an inverse Fourier transform on set of data?
First, you need to determine whether the data are for a one-sided or two-sided Fourier transform, and if the frequency vector ex...

5 years ago | 0

| accepted

Answered
Will not calculate what I need
Use element-wise division (./) in ‘FGH’ and it produces the result you want: FGH = (-(lBE.*Ey.*cosd(alpha))-(lBE.*Ez.*sind(alp...

5 years ago | 0

| accepted

Answered
If loop issue help
An easier way to code that is to use an anonymous function: ds_mapping = @(i) ((0.7 <= i) & (i>= 2.79 )).*1 + ((2.79 < i) & ...

5 years ago | 1

Answered
Get rid of connecting line (3D plot)
One option would be to use either the sort or unique functions (or their friends) on the x-matrix or vector. Those usually wo...

5 years ago | 0

| accepted

Answered
how to find repeated values in array?
See if the approach in this Answer will do what you want.

5 years ago | 0

Answered
use the mat2cell function
Try this: A = randi(9, 5, 100); % Create Matrix To Test Code C = mat2cell(A, ones(5,1), one...

5 years ago | 0

Answered
ss2tf error. The TF does not match.
The bode function accepts state space models as input. See the sys documentation section for an extended discussion. EDIT ...

5 years ago | 0

Answered
Matrix points inside of a sphere
Try this: [X,Y,Z] = sphere(20); ctr = mean([X(:),Y(:),Z(:)]); r = max(Z(:)) - ctr(3); xp = 1-2*rand(150,1); yp = 1-2*ran...

5 years ago | 2

Answered
How to find State Transition Matrix in terms of sin and cos if eigenvalues are Complex Conjugate?
Use the rewrite function, then simplify: A = [0 1; -2 -2]; syms t; A_STM = expm(A*t) A_STM = rewrite(A_STM, 'sincos') A_ST...

5 years ago | 1

| accepted

Answered
To repair the error about classification
The ‘label’ variable must have been defined and must exist in your workspace before it is used as an argument to crossvalind.

5 years ago | 0

| accepted

Answered
Store the outputs of every iteration in while loop in a matrix
There are several errors in the posted code. (I corrected them.) This should do what you want: omega1=100; alfa1=4; beta...

5 years ago | 0

| accepted

Answered
what function to use to find frequency of values in set?
Try this: R12= [5 6 1 2 6 1 2 1 2 6 5 2]; [R12u,~,ix] = unique(R12(:),'stable'); Number = R12u; Count = accumarray(ix,1);...

5 years ago | 1

| accepted

Answered
Why its showing error in array factor?
Create ‘A’ and ‘AF’ as anonymous functions: theta=-2*pi:0.001:2*pi; A = @(theta) 1+exp(j.*(pi/3)-j*(3*pi/4)*cos(theta))+exp(-...

5 years ago | 0

| accepted

Answered
my plot line is not showing line, how do i fix this?
The code needs a bit of tweaking, however the first problem is that ‘cel’ and ‘react’ need to be subscripted, and ‘q’ modified a...

5 years ago | 1

| accepted

Answered
How to concatenate the results of each iteration of a 'for' to create a final concatenated vector?
One option (that does not vary much from the posted code): x{1} = [1 2 3 4 5]; x{2} = [6 7 8 9 10]; x{3} = [11 12 13 14 15];...

5 years ago | 1

Answered
how can I resolve "Duplicate table variable name" error in this piece of code?
If there are duplicate variable names in both tables, it may be necessary to use the join function (or similar functions) to com...

5 years ago | 0

Answered
Matlab is mixing MONTH and DAY up
Try this: D = load('gps.mat'); gps = D.gps; LOCALDATETIME = datetime(string(gps.LOCALDATE),'InputFormat','dd/MM/yyyy', 'Form...

5 years ago | 0

| accepted

Answered
How to remove spikes without modifying the dataset?
Use the isoutlier function: data = [1,2,10,1,3,2,1,2]; TF = isoutlier(data); % Function Intro...

5 years ago | 0

Answered
Reading a text file containing strings.
It would have been appropriate to include the file you want to read. Lacking that, I created my own version (‘Dhanalakshmi M 20...

5 years ago | 0

| accepted

Answered
how to fit trend line in time series
If you have the Statistics and Machine Learning Toolbox, use the refline or refcurve functions. Other options are also linked i...

5 years ago | 0

| accepted

Load more