Answered
Use a for loop for fill this array with the first ten elements of the recursive sequence, then output this array
You have already defined the first two elements of *|‘a’|*, so begin the loop at *|3|* instead: for n=3:10 a(n)=2*(...

9 years ago | 0

| accepted

Answered
Plotting a sine graph with a frequency of 60kHz
Experiment with this: t = linspace(0, 1, 1E+6); y = 4*sin(2*pi*60000*t); figure plot(t, y) grid axis([0...

9 years ago | 0

Answered
2d function in 3d
Try this: x = [1;1] * linspace(-4, 4, 25) ; y = x.^2; figure(1) surf(x, y, [zeros(size(x(1,:))); 5*ones(size(...

9 years ago | 2

| accepted

Answered
I'm a noob and can someone simplify this. I'm trying to make one vector R and one i equation.
Use ordinary vector multiplication to automatically do the multiplication, then take the *|exp|* of that matrix to produce the f...

9 years ago | 1

| accepted

Answered
How to produce a code that will present a grading scale?
I would consider a cumulative distribution function, such as <https://www.mathworks.com/help/stats/normcdf.html *|normcdf|*> (li...

9 years ago | 0

Answered
replace element in the vector without using loops or if statement
It is difficult to help without giving away the solution. To use a logical vector to address the array, see what this examp...

9 years ago | 0

| accepted

Answered
Increase only the axes line width and not the grid line-width
The only way I know to do that is to overplot the axes lines using *|plot3|* (or *|plot|* in 2D). Try this: [X,Y,Z] =...

9 years ago | 1

Answered
How to store 4 outputs in 1 variable?
Try this: [a(1),a(2),a(3),a(4)] = descriptives(b) This assumes *|‘descriptives’|* returns *|4|* separate scalar values....

9 years ago | 0

| accepted

Answered
Hi I want to plot a graph of Z=sin (x) cos(y) , y<3 and x>-3 but I'm unsure on how to code the range. Any help is much appreciated !
Try this: z = @(x,y) sin(x).*cos(y) .* ((x>-3) & (y<3)); [X,Y] = meshgrid(-5:0.5:5); figure(1) surf(X, Y,...

9 years ago | 0

Answered
Finding area under peaks for drifting signal
I would use the Signal Processing Toolbox *|medfilt1()|* function to estimnate the base line drift, that you can then remove. (...

9 years ago | 1

| accepted

Answered
How to plot a vector using stem?
It is difficult to respond without providing at least _some_ code. See the documentation for the <https://www.mathworks.com/hel...

9 years ago | 2

| accepted

Answered
How do I plot in a for loop?
Use the *|bsxfun|* function to automatically expand the vectors: x = linspace(0, 2*pi, 100); A = 1; B = 1; n = 1:...

9 years ago | 0

| accepted

Answered
I need to plot a histogram
This may do what you want. *_The Code_ —* edges = [0 : 0.2 : 1.8, 2.1, 2.7, 3.6, 5.1]; vals = [10 80 132 14...

9 years ago | 3

| accepted

Answered
Sum of matrix elements after using regexp
The numbers are strings, so *|cell2mat|* will concatenate them into one string array. The solution is to use the *|str2doub...

9 years ago | 0

| accepted

Answered
Horizontal bar plot with patch
Try this: figure patch([0 1 1 0],[0 0 1 1], [0.9 0.1 0.1]) hold on patch([0 1 1 0]+1,[0 0 1 1], [0.7 0.0 0.1]) ...

9 years ago | 0

Answered
How to add columns of accumulated sum in a matrix
This seems to work for *|‘C’|*, *|‘D’|* ... *|‘T’|*. This construction seems the only way to form your matrix (that I call ...

9 years ago | 0

| accepted

Answered
With what code can I make Matlab do this operation automatically
Try this: E = sum(exp(x1)) E = 34.8438 You can also create an anonymous function to do this: Efcn =...

9 years ago | 1

| accepted

Answered
want the Negative data be ignored and become postive
Another option: plot(x+k,y+k,'Color') set(gca, 'YLim',[0 max(ylim)])

9 years ago | 0

Answered
Elemination in for loop
Try this: v = 0.1:0.1:1; exclude = [0.3, 0.7, 0.9]; [L1,L2] = ismembertol(v, exclude, 0.01); new_v = v(~L1)

9 years ago | 2

| accepted

Answered
How do I plot the different force values that get calculated in the loop? (This is an equation for the charge of a uniformly charged hoop)
Try this: x = 0:100; r = 10; X = r * x; Ef = zeros(length(X),1); % defines Coulomb's constant k = 8.99E...

9 years ago | 4

| accepted

Answered
how to clear this error?
In general, you cannot define a declared function (using the *|function|* keyword) in a script file. It is best to save it in i...

9 years ago | 0

| accepted

Answered
How to looking for min and max value of curve
Use the Signal Processing Toolbox <https://www.mathworks.com/help/signal/ref/findpeaks.html *|findpeaks|*> (link) function. Fin...

9 years ago | 1

Answered
How to sum specific values from a loop and create a new vector?
Use *|bsxfun|* and *|sum|*: a=1:1:20; b=[0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 2 0 0]; M=[a(:),b(:)]; idx = find(M(:,...

9 years ago | 0

| accepted

Answered
Time-space plot with meshgrid?
Try this: figure(1) scatter(P(:,1), P(:,2), [], P(:,3), 'Filled') grid on colormap(jet(10))

9 years ago | 1

| accepted

Answered
How to read a Matrix from the top left corner to the bottom right corner in a diagonal fashion
This works: M = [1 2 3 4; 5 6 7 8; 3 2 5 4; 9 7 5 4]; Mf = flip(M,1); ref = size(M,1); for k1 = 1:2*ref-1 ...

9 years ago | 0

Answered
Calculate R squared from a linear regress
It depends on the regression you’re doing. If you have a simple bivariable (as opposed to multivariable) linear regression, you...

9 years ago | 2

| accepted

Answered
Interpreation of fitlm results
Put simply, the *|‘Intercept’|* is the *|y|*-axis _intercept_ of the line, and *|‘x1’|*is the _slope_ of your simple linear regr...

9 years ago | 2

Answered
Loading a set of data from a txt file, plotting the data onto a spherical 3D plot (astronomy)
See if this works: % RA DEC A = [00 08.2 +29 04 00 13.1 +15 10 00 25.4 -77...

9 years ago | 1

| accepted

Answered
How to insert function in matlab
If you want to evaluate them as statements: theta = pi/2; % Choose A Value x = linspace(0, 2*...

9 years ago | 0

Answered
how can i get EMG envelope using helbert transform
If you have *|R2015b|* or later, use the <https://www.mathworks.com/help/signal/ref/envelope.html *|envelope|*> (link) function ...

9 years ago | 0

Load more