Community Profile

# Sindar

### University of Colorado Boulder

79 total contributions since 2018

View details...

Contributions in
View by

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

18 hours ago | 0

| accepted

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

18 hours ago | 0

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

18 hours ago | 0

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

18 hours ago | 0

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

18 hours ago | 0

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

3 days ago | 0

| accepted

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

3 days ago | 0

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

4 days ago | 0

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

4 days ago | 0

| accepted

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

5 days ago | 0

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

5 days ago | 0

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

6 days ago | 0

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

6 days ago | 0

| accepted

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

6 days ago | 0

| accepted

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

6 days ago | 1

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

6 days ago | 1

| accepted

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

6 days ago | 2

| accepted

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

6 days ago | 1

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

6 days ago | 0

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

6 days ago | 0

| accepted

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

6 days ago | 0

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

7 days ago | 0

| accepted

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

8 days ago | 0

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

8 days ago | 0

Setting a value for multiple axes handles at once (without a for-loop)
Setting a value for multiple handles is pretty easy: set(axs,'Units','centimeters') getting values is a little trickier. For y...

8 days ago | 0

| accepted

Array of index, should return indexed values on the same array format
It sounds like weights = v(m); should work

10 days ago | 0

How to find the mean of categorical data
check out splitapply. You may need to change the format of your data, but it does exactly what you want: G = findgroups(Day); ...

10 days ago | 0

What is the inversion method used in (inv) function in MATLAB
read the documentation: "inv performs an LU decomposition of the input matrix (or an LDL decomposition if the input matrix is H...

10 days ago | 1

| accepted