Answered
Multiply Matrix by scalar variables?
You need to vectorise the division (replace *|‘/’|* with *|‘./’|*). Then it works: ... CODE .. %Define Dependent Varia...

9 years ago | 2

| accepted

Answered
delete an element in char array without deleting the duplicated elements before it
One approach: str = 'drinking tea'; stra = [str 'ab' 'ab']; idx = strfind(stra, 'ab'); recovered_str = stra(1:idx...

9 years ago | 0

Answered
Weird error when calling a function with parameters
The third argument to *|fsolve|* has to be an *|options|* structure. I have no idea what you are doing with *|‘one’|* and *...

9 years ago | 0

Answered
Plotting several best fit lines for one data series
Unless you have a model of your data that will allow you to specifically estimate the necessary parameters (the best option, usi...

9 years ago | 0

Answered
Using MATLAB to Integrate Data that has a Sinusoidal Signature
The ‘Angular Rate’ signal is offset from zero (the mean appears to be *|0.06|*), and *|cumtrapz|* is integrating that constant o...

9 years ago | 0

| accepted

Answered
if else statements with asking user for input
I prefer the <https://www.mathworks.com/help/matlab/ref/inputdlg.html *|inputdlg|*> (link) function. You can replace your f...

9 years ago | 0

Answered
How to save and use the slope of fitted line in linear curve fitting as a variable in matlab?
If you are referring to the line produced by the *|lsline|* function, this works: figure(1) scatter(1:10, rand(1, 10)) ...

9 years ago | 0

Answered
Error Undefined x!
The *|int|* function is part of the Symbolic Math Toolbox. The most appropriate function is *|integral|*, with the integrand as...

9 years ago | 0

| accepted

Answered
How can Write a function that combines two lists by alternatingly taking elements, e.g. [23,11,70], [1,2,3] → [23,1,11,2,70,3].
Using the *|reshape|* function: A = [23,11,70]; B = [1,2,3]; Out = reshape([A; B], 1, []) Out = 23 ...

9 years ago | 0

| accepted

Answered
Problem in plotting periodic waves
The Signal Processing Toolbox has the <https://www.mathworks.com/help/signal/ref/pulstran.html *|pulstran|*> (link) funciton. ...

9 years ago | 0

Answered
What is the most efficient method to create a vector field plot using a non rectangular dataset?
You didn’t post your code, so I don’t know what you’ve done. If you’ve not already been introduced to the <https://www.math...

9 years ago | 0

| accepted

Answered
Error on converting datestr to datenum
The correct format is *|'yyyy-MM-dd HH:mm:ss'|*. However, there is a much easier way to create your *|datetime|* array: ...

9 years ago | 0

Answered
Genetic Algorithm: Failure in initial user-supplied fitness function evaluation. GA cannot continue.
You need to supply a function with a single vector argument to *|ga|*. This should work: SOL = ga(@(x) AlgoGen(x(1),x...

9 years ago | 5

| accepted

Answered
zeros of a multivariable function
Try this (requires the Optimization Toolbox): syms x1 x2 x3 l a b g a = 0.25; b = 4; g = 0.5; % x1:= x, x2: = ...

9 years ago | 0

Answered
why is Z_mod only one value rather than a matrix in this script
Remember to vectorise the division as well: Z_mod=sqrt(((10.^(alpha*y*2))+(2*c*R_O*(10.^(alpha*y)))+(R_O.^2))./(1+(2*c*(10...

9 years ago | 0

Answered
How to compute Fourier transform of a signal?
The problem is that the constant offset value of your signal is very high compared to the amplitude of the oscillations. I woul...

9 years ago | 0

| accepted

Answered
Intersection of plane and line.
One approach: syms x y z t % x + 2y + 3z = 4 and line (x, y, z) = (2,4,6) + t(1,1,1) xl = 2 + t; yl = 4 + t; ...

9 years ago | 1

| accepted

Answered
What is wrong with my code? I want a letter grade if I enter a number grade but I keep getting an error message.
Your variable is defined as *|‘grade’|*, not *|‘num’|*, in your current code.

9 years ago | 0

Answered
How to find FFT of a non-uniformly sampled data?
Your data are very close to being uniformly sampled. The mean difference in sampling times (sampling interval) is *|976.5623e-0...

9 years ago | 2

| accepted

Answered
Intersection of two planes.
Try this: syms x y z ekv1=x+y+z==3 ekv2=x+2*y+2*z==4 xyz = solve([ekv1, ekv2]) x = xyz.x y = xyz.y ...

9 years ago | 0

| accepted

Answered
Please help with this equation
You need to completely vectorise your equation, including the division: z = sqrt((a.^(2)*e.^(2*d)+2*c*b*a*e.^(d)+b.^2)./(1...

9 years ago | 1

| accepted

Answered
I'm trying to compare two sets of ecg data in a figure. I want the plots to overlay each other. I need to offset so the two line up, any suggestions?
See if the Signal Processing Toolbox <http://www.mathworks.com/help/signal/ref/alignsignals.html *|alignsignals|*> (link) functi...

9 years ago | 0

| accepted

Answered
fitting multiple data simultaneosly
Try this: P1= rand(6,1); V1= rand(6,1); P2= rand(4,1); V2= rand(4,1); P3= rand(7,1); V3= rand(7,1); ...

9 years ago | 2

| accepted

Answered
How to calculate Tangent of angles in degree
Use the *|tand|* function: Angles = [ 40 45 41 43 80 70 60]; TandAngles = tand(Angles) or: TanAngles = tan(Ang...

9 years ago | 2

| accepted

Answered
fplot differentiated symbolic equation
I would calculate the derivative and create the anonymous function for *|‘Vg’|* with: Vg = matlabFunction(diff(Mg,t), 'Var...

9 years ago | 1

| accepted

Answered
Using matrix index coming from max function to get values from another matrix
This seems to work: A = randn(5,5); B = randn(5,5); C = randn(5,5); D = cat(3,A,B,C); E = randn(5,5,3)...

9 years ago | 0

| accepted

Answered
Approximating an Intersection Point Between 2 Sets of Data
Use the *|fzero|* function, subtracting your two polynomials to get the point where the curves intersect: *_Example_ —* ...

9 years ago | 0

Answered
Generate n-dimensional array: problem with 1D
That is as ‘smart’ as it gets, since it cannot read your mind. If you already have a vector and you want a *|zeros|* vector to ...

9 years ago | 0

| accepted

Answered
splitting an array into unequal parts without loop
Use the *|mat2cell|* function: v_in = rand(1,100); % length = 100 n = [10 20 10 10 15 25 10]; % length = 7 Out = mat...

9 years ago | 2

| accepted

Answered
Editing Figure to Create Equilateral Triangle
Your triangle should have a height of *|50|*, not *|100|*. This will outline the triangle as equilateral: f1=f...

9 years ago | 0

Load more