Respondida
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...

casi 6 años hace | 0

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

casi 6 años hace | 0

Respondida
how to find duration of peak; starting and ending points
widths are an optional output from findpeaks: [pks,locs,widths,~] = findpeaks(data);

casi 6 años hace | 0

Respondida
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...

casi 6 años hace | 0

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

casi 6 años hace | 0

| aceptada

Respondida
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...

casi 6 años hace | 0

| aceptada

Respondida
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 ...

alrededor de 6 años hace | 0

| aceptada

Respondida
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: >...

alrededor de 6 años hace | 0

Respondida
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];...

alrededor de 6 años hace | 0

Respondida
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...

alrededor de 6 años hace | 0

Respondida
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])

alrededor de 6 años hace | 0

Respondida
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...

alrededor de 6 años hace | 1

| aceptada

Respondida
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...

alrededor de 6 años hace | 0

Respondida
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...

alrededor de 6 años hace | 0

Respondida
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...

alrededor de 6 años hace | 0

| aceptada

Respondida
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...

alrededor de 6 años hace | 0

Respondida
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] ...

alrededor de 6 años hace | 0

Respondida
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...

alrededor de 6 años hace | 0

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

alrededor de 6 años hace | 0

| aceptada

Respondida
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...

alrededor de 6 años hace | 0

| aceptada

Respondida
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...

alrededor de 6 años hace | 1

Respondida
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...

alrededor de 6 años hace | 1

| aceptada

Respondida
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 ...

alrededor de 6 años hace | 2

| aceptada

Respondida
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...

alrededor de 6 años hace | 1

Respondida
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...

alrededor de 6 años hace | 0

| aceptada

Respondida
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:...

alrededor de 6 años hace | 0

| aceptada

Respondida
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...

alrededor de 6 años hace | 0

Respondida
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...

alrededor de 6 años hace | 0

| aceptada

Respondida
Transform char variable to matrix
tmp={'002,005';'002,003';'002,005'}; NewVar=str2double(split(tmp,','))

alrededor de 6 años hace | 0

Respondida
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...

alrededor de 6 años hace | 0

Cargar más