Answered

Could anyone help me how to make the values to be repeated again after 800 iterations for a total of 1000 iterations.

If I understand you correctly, you have data in, let's say, x. You want to set elements 801-1000 of x equal to element 800: x(8...

Could anyone help me how to make the values to be repeated again after 800 iterations for a total of 1000 iterations.

If I understand you correctly, you have data in, let's say, x. You want to set elements 801-1000 of x equal to element 800: x(8...

4 days ago | 0

Answered

Colormap for multline plot

I believe this should work: mylines = plot(t, x); set(mylines,{'Color'},flag(length(mylines))) For 2019b+, colororder is ...

Colormap for multline plot

I believe this should work: mylines = plot(t, x); set(mylines,{'Color'},flag(length(mylines))) For 2019b+, colororder is ...

4 days ago | 0

Answered

how to find duration of peak; starting and ending points

widths are an optional output from findpeaks: [pks,locs,widths,~] = findpeaks(data);

how to find duration of peak; starting and ending points

widths are an optional output from findpeaks: [pks,locs,widths,~] = findpeaks(data);

4 days ago | 0

Answered

How to convert .mat file to png format?

This is not generally possible. mat files store variables, not images. This is like asking "how do I convert a flashdrive into a...

How to convert .mat file to png format?

This is not generally possible. mat files store variables, not images. This is like asking "how do I convert a flashdrive into a...

4 days ago | 0

Answered

Save variables in a folder

Check the save documentation, you can save specific variables by adding their names as further inputs: save(resultFileName,'Err...

Save variables in a folder

Check the save documentation, you can save specific variables by adding their names as further inputs: save(resultFileName,'Err...

4 days ago | 0

| accepted

Answered

Why it gives Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters

This would be much easier to solve if you included the full error text. But, I suspect the problem is here: function H = hpfil...

Why it gives Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched delimiters

This would be much easier to solve if you included the full error text. But, I suspect the problem is here: function H = hpfil...

4 days ago | 0

Answered

Delete and merge rows and columns based on values of other matrix

If I understand correctly: You have one NxN matrix A And a second 1xN vector B When an element of B is zero, you delete rows ...

Delete and merge rows and columns based on values of other matrix

If I understand correctly: You have one NxN matrix A And a second 1xN vector B When an element of B is zero, you delete rows ...

7 days ago | 0

| accepted

Answered

Could anyone please help me to do matrix multiplication with respect to the sample data given below.

Matrix multiplication only works when the "middle" dimension matches ( N x M ) * ( M x O ) Check the sizes of your matrices: >...

Could anyone please help me to do matrix multiplication with respect to the sample data given below.

Matrix multiplication only works when the "middle" dimension matches ( N x M ) * ( M x O ) Check the sizes of your matrices: >...

7 days ago | 0

Answered

Could anyone help me how to multiply the second and third element of the row in a matrix by an value of 2 and 3.

A=[ 2 3 4]; A(2) = A(2)*2; A(3) = A(3)*3; More generally, you can use elementwise multiplication: A=[ 2 3 4 5 6 7 8];...

Could anyone help me how to multiply the second and third element of the row in a matrix by an value of 2 and 3.

A=[ 2 3 4]; A(2) = A(2)*2; A(3) = A(3)*3; More generally, you can use elementwise multiplication: A=[ 2 3 4 5 6 7 8];...

7 days ago | 0

Answered

How can I create array of numbers +5 the previous number?

start_num = 1; end_num = 15; x=[start_num:5:end_num]; % note that 15 is not included since 1+5+5+5=16 If you actually want t...

How can I create array of numbers +5 the previous number?

start_num = 1; end_num = 15; x=[start_num:5:end_num]; % note that 15 is not included since 1+5+5+5=16 If you actually want t...

7 days ago | 0

Answered

How can I xticks at equal distance

Assuming you want them equally spaced because they are equally spaced on a log scale: semilogx(F_x,K) xticks([0.1 1 10])

How can I xticks at equal distance

Assuming you want them equally spaced because they are equally spaced on a log scale: semilogx(F_x,K) xticks([0.1 1 10])

7 days ago | 0

Answered

Calculating the eigenvalues of a composite matrix

You are overwriting V,D,W every time. The simplest way to avoid this, ignoring the specific size of the variables, is to put the...

Calculating the eigenvalues of a composite matrix

You are overwriting V,D,W every time. The simplest way to avoid this, ignoring the specific size of the variables, is to put the...

9 days ago | 0

| accepted

Answered

How to save a table as a CSV in a folder within the directory

writetable(T,'subfolder/myData.csv','Delimiter',',') if 'subfolder' doesn't already exist, you may need to make it: mkdir('sub...

How to save a table as a CSV in a folder within the directory

writetable(T,'subfolder/myData.csv','Delimiter',',') if 'subfolder' doesn't already exist, you may need to make it: mkdir('sub...

9 days ago | 0

Answered

I'm trying to create a matrix with the following format for any size square matrix.

I believe this spdiags example is exactly what you want: https://www.mathworks.com/help/matlab/ref/spdiags.html#mw_28033fbc-1469...

I'm trying to create a matrix with the following format for any size square matrix.

I believe this spdiags example is exactly what you want: https://www.mathworks.com/help/matlab/ref/spdiags.html#mw_28033fbc-1469...

10 days ago | 0

Answered

How can I replace the maximum value in every column in matrix A (38 x 13390) by 1 in matrix B (38 x 13390) in the same cell of every column in matrix A

A=rand(38,13390); % find the max elements M for each column and the indices I % 'linear' returns linear indices instead of row...

How can I replace the maximum value in every column in matrix A (38 x 13390) by 1 in matrix B (38 x 13390) in the same cell of every column in matrix A

A=rand(38,13390); % find the max elements M for each column and the indices I % 'linear' returns linear indices instead of row...

10 days ago | 0

| accepted

Answered

Coding a quadratic root finder

One error: you want to check the sign of (b*b-4*a*c), not sqrt(b*b-4*a*c) The case of two complex roots works exactly like tw...

Coding a quadratic root finder

One error: you want to check the sign of (b*b-4*a*c), not sqrt(b*b-4*a*c) The case of two complex roots works exactly like tw...

12 days ago | 0

Answered

How can I generate a colour map of points based on their distance from a plane?

I haven't tested, but I think something like this should work: % bin b1 & b2 into 10 & 30 bins, respectively [b1_bin,b1_edge] ...

How can I generate a colour map of points based on their distance from a plane?

I haven't tested, but I think something like this should work: % bin b1 & b2 into 10 & 30 bins, respectively [b1_bin,b1_edge] ...

12 days ago | 0

Answered

Is there a way to put a marker on all of the points where y=0 on a plot?

Assuming you have access to the data (x,y) which generated the plot: % generate sample x,y x=1:1000; % generate 1000 random i...

Is there a way to put a marker on all of the points where y=0 on a plot?

Assuming you have access to the data (x,y) which generated the plot: % generate sample x,y x=1:1000; % generate 1000 random i...

12 days ago | 0

Answered

indexing into a matrix

A([1 3 end-1],:) I highly recommend this explanation of indexing: https://www.mathworks.com/company/newsletters/articles/matrix...

indexing into a matrix

A([1 3 end-1],:) I highly recommend this explanation of indexing: https://www.mathworks.com/company/newsletters/articles/matrix...

12 days ago | 0

| accepted

Answered

aggregate data of a dataset

check out splitapply. You may need to change the format of your data, but it does exactly what you want: G = findgroups(ds.seat...

aggregate data of a dataset

check out splitapply. You may need to change the format of your data, but it does exactly what you want: G = findgroups(ds.seat...

12 days ago | 0

| accepted

Answered

Array indices must be positive integers or logical values.

You are trying to access Re(i),V(i),etc. with i=1.02. There doesn't seem to be anywhere that you use i as a number rather than i...

Array indices must be positive integers or logical values.

You are trying to access Re(i),V(i),etc. with i=1.02. There doesn't seem to be anywhere that you use i as a number rather than i...

12 days ago | 1

Answered

How do I replace an image on a graph and replace it with a new image, whilst keeping all other images in their place?

ball_handle = fill(x,y,c); %or secondhand through drawshapeNew ... ball_handle.Vertices = ball_handle.Vertices + [xtranslate y...

How do I replace an image on a graph and replace it with a new image, whilst keeping all other images in their place?

ball_handle = fill(x,y,c); %or secondhand through drawshapeNew ... ball_handle.Vertices = ball_handle.Vertices + [xtranslate y...

12 days ago | 1

| accepted

Answered

how to Obtain the algebraic and geometric multiplicity of each eigenvalue of any square matrix

eig(A) gives you the eigenvalues. You can count occurrences for algebraic multiplicity. Geometric seems more complicated, but I ...

how to Obtain the algebraic and geometric multiplicity of each eigenvalue of any square matrix

eig(A) gives you the eigenvalues. You can count occurrences for algebraic multiplicity. Geometric seems more complicated, but I ...

13 days ago | 2

| accepted

Answered

How do I replace an image on a graph and replace it with a new image, whilst keeping all other images in their place?

Depending on how you are drawing the ball, you may be able to update it's position rather than drawing a new one. If not, you co...

How do I replace an image on a graph and replace it with a new image, whilst keeping all other images in their place?

Depending on how you are drawing the ball, you may be able to update it's position rather than drawing a new one. If not, you co...

13 days ago | 1

Answered

using break and continue to using true extend ?

It sounds like you want to check the conditions with if statements inside your while loop: while true % do stuff Mass...

using break and continue to using true extend ?

It sounds like you want to check the conditions with if statements inside your while loop: while true % do stuff Mass...

13 days ago | 0

Answered

using non number vectors and number vectors in the same fprintf command (beginner)

There is no good reason to do this in a single fprintf command, and the workaround necessary to do it would be painful. Do this:...

using non number vectors and number vectors in the same fprintf command (beginner)

There is no good reason to do this in a single fprintf command, and the workaround necessary to do it would be painful. Do this:...

13 days ago | 0

| accepted

Answered

changing a group of numbers in a vector

Does this do it or do you need individual cycles to be different lengths? % total number of elements N = 3501; % number of "o...

changing a group of numbers in a vector

Does this do it or do you need individual cycles to be different lengths? % total number of elements N = 3501; % number of "o...

13 days ago | 0

Answered

Random Number Generator with range between numbers

instead of (weighted) averaging your old velocity and a new random velocity, just modify your old velocity by a smaller random n...

Random Number Generator with range between numbers

instead of (weighted) averaging your old velocity and a new random velocity, just modify your old velocity by a smaller random n...

14 days ago | 0

| accepted

Answered

Transform char variable to matrix

tmp={'002,005';'002,003';'002,005'}; NewVar=str2double(split(tmp,','))

Transform char variable to matrix

tmp={'002,005';'002,003';'002,005'}; NewVar=str2double(split(tmp,','))

14 days ago | 0

Answered

How to plot and save a figure with consolidated plots as well as splitted plots in loop?

Presumably you are calculating or loading each batch. To distinguish in this simple example, I add the index to the data x=[1:5...

How to plot and save a figure with consolidated plots as well as splitted plots in loop?

Presumably you are calculating or loading each batch. To distinguish in this simple example, I add the index to the data x=[1:5...

14 days ago | 0