Community Profile

# Sindar

### University of Colorado Boulder

70 total contributions since 2018

View details...

Contributions in
View by

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

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

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

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

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

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

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

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

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

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

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

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

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

3 days ago | 0

| accepted

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

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

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

3 days ago | 0

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

5 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); ...

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

5 days ago | 1

| accepted

How would one tablize the iterations from a while loop with the variables at the top?
something like this will work, but may not be the most efficient depending on the number of iterations: tol = 1e-5; c_old = In...

5 days ago | 0

Error: Array indices must be positive integers or logical values. Why??
you need a '*' between 'z' and the parenthesis. It is interpreting z(...) as indexing z

5 days ago | 0

how to find max value of a function with a for loop
Loop isn't necessary unless you can't store the data in memory: e=y-(m*x-b); [e_max,idx] = max(e); x_max = x(idx); y_max = y...

7 days ago | 0

Storing all for-loop results of a specific variable in .mat-file
Assuming all the produced data can fit in memory: for ta=1:20 a = 3; % save each value in an array va(ta) = (ta.*a)...

7 days ago | 0

Select Specific Values in Matrix Based on Index Values Listed in Array...
Actually, you can index directly with 'b' after loading your variable into 'a': a(b,:) It may be possible to only load the row...

7 days ago | 0

| accepted

For loop and indexing help
check out the discretize function

12 days ago | 0

How to add both title and change the scale of a color bar
cb=colorbar(); cb.Label.String = 'Electric Potential Field, V'; cb.Ticks = -45:15:150; caxis([-45 150]);

12 days ago | 0

| accepted

How to locate significant points in a graph?
check out findpeaks

19 days ago | 0

Using the result as a input in the loop again
Change Mw1(x)=(mW+M(x)/18.0); to % first iteration assumes Mw1(0) = 0 if x==1 Mw1(x)=mW; % later loops access the valu...

19 days ago | 0

| accepted

How to sort a matrix by a predefined order
A=[1 2; 7 8; 5 6; 3 4]; B=[1; 4; 3; 2]; A = A(B,:);

19 days ago | 0

| accepted