Answered
how to add a constant to all the elements of the matrix?
Since ‘implicit expansion’ arrived in *|R2016b|*, this will work: A = rand(3); B = A + 5; or: B = A * 5; Fo...

8 years ago | 2

Answered
while using "find" on a vector I get "Empty matrix: 1-by-0" on certain values
The *|round|* function is not part of the problem. The inexact results of floating point calculations are. See <http://matlab....

8 years ago | 0

| accepted

Answered
Matching loop, for similar values
If I understand correctly what you want to do, the <https://www.mathworks.com/help/matlab/ref/ismembertol.html *|ismembertol|*> ...

8 years ago | 0

Answered
How to insert columns into an existing matrix without deleting existing columns?
Try this: matrix = rand(10,8); index_excl = [0 0 1 0 0 0 0 1 0 0 1] > 0; AddCols = nnz(index_exc...

8 years ago | 0

| accepted

Answered
What can I do to filter my EMG data(.csv) in Matlab?
My *_guess_* is that the first column is the sampling times, and the second is your EMG data. If so, try something like thi...

8 years ago | 0

Answered
Use ODE45 to solve a system of two coupled second order ODEs
I prefer to let the Symbolic Math Toolbox do these derivations: syms c1 c2 k1 k2 m1 m2 t Ftfcn x1(t) x2(t) Y %x1''=(F(...

8 years ago | 0

| accepted

Answered
How to state a while condition to prevent an action?
You can test for the presence of the *|‘.dcm’|* extension easily enough: has_dcm = ~isempty(strfind(filename, '.dcm')); ...

8 years ago | 0

Answered
Is it possible to get the MAC adress of the computer by MATLAB?
<https://blogs.mathworks.com/pick/2017/11/10/mac-address/ *Get Computer MAC Address*> (link).

8 years ago | 0

Answered
Histogram gives different BinCounts while appending BinEdges
You have different numbers of bins in each *|subplot|*. In *|subplot(3,1,1)|*, you define *|61|* bins, in *|subplot(3,1,2)|*, *...

8 years ago | 0

Answered
plotting dates over continuous numeric data
Converting your *|‘t’|* values to date numbers and then to *|datetime|* or similar formats is likely going to be an unproductive...

8 years ago | 0

Answered
Replacing array with a subset of another array
One approach: A=[1;2;3;4]; B=[0;0;0;0;0;0]; C = B; C(1:numel(A)) = A;

8 years ago | 0

Answered
How to get ode45 to work with my function?
Your code is not easy to follow. My _guess_ is that this line is throwing the error: k = kt*exp((E/R2)*((1/T0)-(1/f))...

8 years ago | 0

| accepted

Answered
Ode solver include specific time point
I would use the <https://www.mathworks.com/help/matlab/ref/deval.html *|deval|*> (link) function to evaluate your solved ODE at ...

8 years ago | 0

| accepted

Answered
Manipulating X-Axis Values
One approach: x = ...; y = ...; figure(1) plot(x, y) grid xt = get(gca, 'XTick'); xtl = linspace(197...

8 years ago | 0

| accepted

Answered
What is the best way to flip part of the graph about the x axis in MATLAB ?
Multiply the *|y|*-values by *|-1|* to ‘flip’ it. This is the best way, and one you can use with the *|findpeaks|* function to ...

8 years ago | 0

Answered
passing struct to a function
The single quotes create your *|‘PRT’|* structure as a character array: *|'PRT'|*. As best I can determine, this would be t...

8 years ago | 0

| accepted

Answered
sprintf: how to efficiently create a string of 75 numbers, separated by comma
You can still use *|sprintf|*. You just need to create a ‘dynamic’ format string: A = 1:5; str = sprintf([repmat('%d,'...

8 years ago | 1

| accepted

Answered
Fitting Data into a model
I would do this: fluor_fcn = @(b,t) 1 - exp(b.*t); % Model Function t = linsp...

8 years ago | 0

Answered
AS I am plotting a graph like the one shown next, I am trying to flip the lowest peak values about the x axis?
If I understand correctly what you want to do, multiply it by *|-1|* to invert it, and reflect it to below *|y=0|*.

8 years ago | 0

Answered
Need help with 3D-plot
The image in your Question is a Signal Processing Toolbox <https://www.mathworks.com/help/signal/ref/spectrogram.html *|spectrog...

8 years ago | 1

| accepted

Answered
Replace the symbol with value ?
The easiest way is simply to define the values _before_ defining *|‘T1’|*: syms O1 L1 L1 = 1; O1 = 0; T1 = [cos(...

8 years ago | 0

Answered
Replace the symbolic with values ?
The easiest way is to define the values before defining *|‘T1’|*: syms O1 L1 L1 = 1; O1 = 0; T1 = [cos(O1),0,sin...

8 years ago | 0

Answered
How do you make a 2D plot where the x-axis represents more than one variable
See the documentation for the <https://www.mathworks.com/help/matlab/ref/subplot.html *|subplot|*> (link) function.

8 years ago | 0

| accepted

Answered
how do i plot the matrice T for a range of w? Also, how to get several matrices B by varying w
Try this: M = 250; d = 0.02; %diameter of surge pipe in meters% p0 = 1.225; %mean density of air in kg/m^3% Rf = ...

8 years ago | 0

Answered
How to plot a probability distribution object?
Use the *|pdf|* function: pd = makedist('Normal','mu',75,'sigma',10); x = 25:125; y = pdf(pd, x); figure p...

8 years ago | 2

| accepted

Answered
Help using besselh to plot data
MATLAB is interpreting *|‘j’|* here as the imaginary operator: X = ((2*besselj(1,x))./(x)) + ((j).*((2*bessely(1,x))./(x))...

8 years ago | 0

| accepted

Answered
How to avoid connecting data points on a plot when there is a gap in data?
Try this: x = [20:10:120 150 160]; y = rand(3, size(x,2))*1E+4; didx = [(diff(x) > 10) false ]; x(didx) = NaN...

8 years ago | 2

Answered
How do I save a value from an iteration of a for loop?
First, rename the *|‘hold’|* variable to something that does not overshadow a MATLAB function. (I renamed it *|‘env’|*.) Then,...

8 years ago | 1

| accepted

Answered
How can I make a line discontinue when it intersects with another line and display the intersection points?
Using the <https://www.mathworks.com/help/matlab/ref/mrdivide.html *|mrdivide,/|*> (link) function and some elementary algebra w...

8 years ago | 0

| accepted

Answered
Solve for coefficients of a function
I am _guessing_ that your system is linear. If so, you can calculate the *|(1xn)|* vector of *|‘alpha’|* coefficients as: ...

8 years ago | 0

| accepted

Load more