RANK**161**

REPUTATION**508**

CONTRIBUTIONS

**4** Questions

**186** Answers

ANSWER ACCEPTANCE **
50.0%
**

VOTES RECEIVED**50**

CONTRIBUTIONS**0 Posts**

CONTRIBUTIONS**0** Public Channels

AVERAGE RATING

CONTRIBUTIONS**0** Highlights

AVERAGE NO. OF LIKES

Answered

Excel Variables and Data Analysis

I'm attaching some fake data I put together that match the description of your data. Given this, here's some code to answer you...

Excel Variables and Data Analysis

I'm attaching some fake data I put together that match the description of your data. Given this, here's some code to answer you...

5 hours ago | 0

Answered

Find the index of specific values in my matrix

No need for loops. Just use the ind2sub function: A = [0 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0] [x, y] = ind2sub(...

Find the index of specific values in my matrix

No need for loops. Just use the ind2sub function: A = [0 0 1 0 1 0 1 0 1 0 0 1 1 0 1 0 1 0] [x, y] = ind2sub(...

9 hours ago | 1

| accepted

Answered

remove empty rows of a cell

reshape(K(~cellfun('isempty',K)), [], size(K,2))

remove empty rows of a cell

reshape(K(~cellfun('isempty',K)), [], size(K,2))

11 hours ago | 0

Answered

How to add text on the figure without unknown x and y coordinates ?

To print 'hello' in the center of the figure... (adjust accordingly) ax = gca; x = ax.XLim(1) + (ax.XLim(2) - ax.XLim(1)) / 2;...

How to add text on the figure without unknown x and y coordinates ?

To print 'hello' in the center of the figure... (adjust accordingly) ax = gca; x = ax.XLim(1) + (ax.XLim(2) - ax.XLim(1)) / 2;...

14 hours ago | 0

Answered

What is the problem in my for loops?

You don't need nested loops: m = 12; n = 2; p = 100; fprintf('\nColumn 1\t\tColumn 2\n'); for i = 0:n:m a = 2....

What is the problem in my for loops?

You don't need nested loops: m = 12; n = 2; p = 100; fprintf('\nColumn 1\t\tColumn 2\n'); for i = 0:n:m a = 2....

18 hours ago | 0

| accepted

Answered

How to make graphic get the same color as the colorbar?

I think this achieves what you are after. Use mesh, instead of plot3, and the mesh colors will be linked to the colorbar: % yo...

How to make graphic get the same color as the colorbar?

I think this achieves what you are after. Use mesh, instead of plot3, and the mesh colors will be linked to the colorbar: % yo...

1 day ago | 1

| accepted

Answered

Measuring distance in 2D plot

Just adding this to the end of your code achieves what you are after (I think). The x-length of the line easy enough to calcula...

Measuring distance in 2D plot

Just adding this to the end of your code achieves what you are after (I think). The x-length of the line easy enough to calcula...

1 day ago | 0

| accepted

Answered

Variables in matrix not updating from for loop

I think this is what you are looking for. It updates k in the z matrix in each iteration of the loop. The max values accumulat...

Variables in matrix not updating from for loop

I think this is what you are looking for. It updates k in the z matrix in each iteration of the loop. The max values accumulat...

1 day ago | 1

| accepted

Answered

How to choose the middle of a random cell in a 2D grid

This solution is simpler. It creates the grid using lines instead of a mesh. % x axis smin = 0; L = 4; ns = 25; s = lin...

How to choose the middle of a random cell in a 2D grid

This solution is simpler. It creates the grid using lines instead of a mesh. % x axis smin = 0; L = 4; ns = 25; s = lin...

1 day ago | 0

Answered

Read elements on one side of matrix diagonal into a 1D array

There might be a tighter solution, but I think this achieves what you are after: a = magic(4) b = a'; c = logical(triu(ones(4...

Read elements on one side of matrix diagonal into a 1D array

There might be a tighter solution, but I think this achieves what you are after: a = magic(4) b = a'; c = logical(triu(ones(4...

2 days ago | 0

| accepted

Answered

How do you write a nested if statement that checks if the user has entered certain numbers?

This is an example of input validation. Here's one method that achieves what you are after. The prompt is repeated until the u...

How do you write a nested if statement that checks if the user has entered certain numbers?

This is an example of input validation. Here's one method that achieves what you are after. The prompt is repeated until the u...

2 days ago | 1

| accepted

Answered

Creating index and replacing values

Below is a loop solution. There might be a way to vectorize this -- not sure. A = [0 0 1 0 1 0 0]; B = [ "030121", "030221", ...

Creating index and replacing values

Below is a loop solution. There might be a way to vectorize this -- not sure. A = [0 0 1 0 1 0 0]; B = [ "030121", "030221", ...

2 days ago | 0

Answered

How to find multiple table column numbers by column names?

col_ind_rmt = find(string(G_Value.Properties.VariableNames) == "rk_mill_tonnage" | ... string(G_Value.Properties.VariableNa...

How to find multiple table column numbers by column names?

col_ind_rmt = find(string(G_Value.Properties.VariableNames) == "rk_mill_tonnage" | ... string(G_Value.Properties.VariableNa...

2 days ago | 0

| accepted

Answered

How to choose the middle of a random cell in a 2D grid

OK, thanks for the clarification. I think this achieves what you are after. The added code randomly chooses vertices (points) ...

How to choose the middle of a random cell in a 2D grid

OK, thanks for the clarification. I think this achieves what you are after. The added code randomly chooses vertices (points) ...

3 days ago | 0

| accepted

Answered

Customed distance function Haversine

You need to re-work your haversine function, as per the requirements for distance functions used with pdist2. There needs to be...

Customed distance function Haversine

You need to re-work your haversine function, as per the requirements for distance functions used with pdist2. There needs to be...

3 days ago | 0

Answered

Verifying an Vector composition

There is probably an easier approach, but I think this works. The result of this expression is 1 if a1<a2<a3<a4<a5, or 0 otherw...

Verifying an Vector composition

There is probably an easier approach, but I think this works. The result of this expression is 1 if a1<a2<a3<a4<a5, or 0 otherw...

4 days ago | 1

Answered

how can I sweep a triangle area using two loops

No need for loops. The tests are built in to the inpolygon function when you provide matrices as input. Assuming you want to f...

how can I sweep a triangle area using two loops

No need for loops. The tests are built in to the inpolygon function when you provide matrices as input. Assuming you want to f...

4 days ago | 0

Answered

HOW TO FILTER AN HOUR DATA FROM ARRAY OF DAILY,MONTHLY AND YEAR DATA

T = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/658625/SAMPLE%20DATA.xlsx'); % combine DATE and...

HOW TO FILTER AN HOUR DATA FROM ARRAY OF DAILY,MONTHLY AND YEAR DATA

T = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/658625/SAMPLE%20DATA.xlsx'); % combine DATE and...

4 days ago | 0

Answered

How to duplicate cell array by rows?

n = handles.times; % your integer value newSequence = repmat(sequence, 1, n);

How to duplicate cell array by rows?

n = handles.times; % your integer value newSequence = repmat(sequence, 1, n);

5 days ago | 0

| accepted

Answered

integral of a matrix

You note: I want to take the integral of an exponetial of a matrix But, exp(-M.*t)*Dmat; is a vector, not a matrix. Tr...

integral of a matrix

You note: I want to take the integral of an exponetial of a matrix But, exp(-M.*t)*Dmat; is a vector, not a matrix. Tr...

5 days ago | 0

Answered

Help rewritting textfiles in a certain way

This can probably be streamlined, but I think it achieves what you are looking for: % read the test data into a 1x1 cell and co...

Help rewritting textfiles in a certain way

This can probably be streamlined, but I think it achieves what you are looking for: % read the test data into a 1x1 cell and co...

5 days ago | 1

| accepted

Answered

How to get row and column from a vector size

Assuming the vector length being a prime number (as noted by @the cyclist) is just one possible case of many, then the following...

How to get row and column from a vector size

Assuming the vector length being a prime number (as noted by @the cyclist) is just one possible case of many, then the following...

5 days ago | 0

| accepted

Answered

How to plot based on the shortest vector?

So, the approach I think you are willing to take is just to ignore the few extra elements that are in the longer of the two vect...

How to plot based on the shortest vector?

So, the approach I think you are willing to take is just to ignore the few extra elements that are in the longer of the two vect...

5 days ago | 1

Answered

Best equation for Curve Fitting

How about r = .9999? Linear model Poly9: f(x) = p1*x^9 + p2*x^8 + p3*x^7 + p4*x^6 + p5*x^5 + p6*x^4...

Best equation for Curve Fitting

How about r = .9999? Linear model Poly9: f(x) = p1*x^9 + p2*x^8 + p3*x^7 + p4*x^6 + p5*x^5 + p6*x^4...

6 days ago | 0

Answered

How can a 4 element array index pull stored string values?

I think this is more or less what you are after. The output is generated both as a cell array and as a string vector. % create...

How can a 4 element array index pull stored string values?

I think this is more or less what you are after. The output is generated both as a cell array and as a string vector. % create...

6 days ago | 1

| accepted

Answered

Using System.DateTime in a Timetable

This converts the System.DateTime variable returned by netTime to a datetime variable, which can then be used with timetable: t...

Using System.DateTime in a Timetable

This converts the System.DateTime variable returned by netTime to a datetime variable, which can then be used with timetable: t...

6 days ago | 0

| accepted

Answered

Change color of x axis and y axis barplot

I think this achieves what you are after. Note that plotyy is "not recommended". a = [rand(3,1)*100, zeros(3,1)]; b = [zeros(...

Change color of x axis and y axis barplot

I think this achieves what you are after. Note that plotyy is "not recommended". a = [rand(3,1)*100, zeros(3,1)]; b = [zeros(...

6 days ago | 0

| accepted

Answered

Scatter Plot Legend Issue With Assignment

You only need to call the scatter function once. Re-organize your data, combining the values into a matrix. Then, you'll get ...

Scatter Plot Legend Issue With Assignment

You only need to call the scatter function once. Re-organize your data, combining the values into a matrix. Then, you'll get ...

6 days ago | 1

Answered

Do error bars affect confidence intervals?

You note: when I use the errorbar function in the code of the fit, it doesn't seem to change the confidence intervals The ...

Do error bars affect confidence intervals?

You note: when I use the errorbar function in the code of the fit, it doesn't seem to change the confidence intervals The ...

7 days ago | 0

Answered

Help with plotting data in a mat file

I think the error might be in how you are verifying your script. I ran your script and generated the plots. Here is what I see ...

Help with plotting data in a mat file

I think the error might be in how you are verifying your script. I ran your script and generated the plots. Here is what I see ...

7 days ago | 0

| accepted