Answered

store the index of nanvalues

Just an approach with cellarrays. A = [1 2 3 4 3 NaN NaN 5 NaN 7]; res = cellfun(@(x) find(~...

store the index of nanvalues

Just an approach with cellarrays. A = [1 2 3 4 3 NaN NaN 5 NaN 7]; res = cellfun(@(x) find(~...

2 years ago | 0

Answered

Extracting a result of a looped finction from the workspace

You're replacing the value of tmp during every iteration. Pre-allocate tmp with a proper size and store every iteration at its r...

Extracting a result of a looped finction from the workspace

You're replacing the value of tmp during every iteration. Pre-allocate tmp with a proper size and store every iteration at its r...

2 years ago | 0

| accepted

Answered

Find the attachment of the xls file that has the student ID, Name, Branch and others ( total 7 coloums )

If you're using tables, store your filtered data in a new table and use writetable T = your_actual_table; T_filtered = T(T...

Find the attachment of the xls file that has the student ID, Name, Branch and others ( total 7 coloums )

If you're using tables, store your filtered data in a new table and use writetable T = your_actual_table; T_filtered = T(T...

2 years ago | 1

| accepted

Answered

Add numbers in a plot

Assuming you know how to plot circles, you could use text command right after you plot the circle, text(x,y,['(',num2str(x),...

Add numbers in a plot

Assuming you know how to plot circles, you could use text command right after you plot the circle, text(x,y,['(',num2str(x),...

2 years ago | 0

Answered

Time series with date

if you're using 2013b or later, use readtable. Very simple, T = readtable('filename.csv'); then if you have 2016b or late...

Time series with date

if you're using 2013b or later, use readtable. Very simple, T = readtable('filename.csv'); then if you have 2016b or late...

2 years ago | 0

Answered

Converting from 1 x n x 3 to n x 3

squeeze(your_matrix) eg: squeeze(1xnx3) gives you nx3 matrix

Converting from 1 x n x 3 to n x 3

squeeze(your_matrix) eg: squeeze(1xnx3) gives you nx3 matrix

2 years ago | 0

| accepted

Answered

clear plot and add a new plot to the current figure

You probably want to use |clf| <https://www.mathworks.com/help/matlab/ref/clf.html> f = figure(1) plot something clf(...

clear plot and add a new plot to the current figure

You probably want to use |clf| <https://www.mathworks.com/help/matlab/ref/clf.html> f = figure(1) plot something clf(...

2 years ago | 0

Answered

why doubling is done from 2 to end-1 only in plotting single sided spectrum: P1(2:end-1) = 2*P1(2:end-1); ?

You probably need to read about matrix indexing. <https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-m...

why doubling is done from 2 to end-1 only in plotting single sided spectrum: P1(2:end-1) = 2*P1(2:end-1); ?

You probably need to read about matrix indexing. <https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-m...

2 years ago | 0

Answered

Finding average value of multiple Y values for a single x value

A lot depend on how you have stored your data. I can think of something with table. You could either sort your data into a table...

Finding average value of multiple Y values for a single x value

A lot depend on how you have stored your data. I can think of something with table. You could either sort your data into a table...

2 years ago | 1

Answered

If Loop for specific condition

is it a homework? should you really use for loop and if-else statements? I suppose yes. In that case, you need to store your ...

If Loop for specific condition

is it a homework? should you really use for loop and if-else statements? I suppose yes. In that case, you need to store your ...

2 years ago | 0

| accepted

Answered

how to read and change entries in a large array

It's easier to answer with an example. Let's say we have a matrix of 5x5 with random numbers and you want to find the elements t...

how to read and change entries in a large array

It's easier to answer with an example. Let's say we have a matrix of 5x5 with random numbers and you want to find the elements t...

2 years ago | 1

| accepted

Answered

how to look for repetions in a matrix with condition on the last column

You just need to use indexing with find to get the indices of the rows that fullfil your condition, A = [0 1 0 2 1 ; 0 1...

how to look for repetions in a matrix with condition on the last column

You just need to use indexing with find to get the indices of the rows that fullfil your condition, A = [0 1 0 2 1 ; 0 1...

2 years ago | 1

| accepted

Answered

Extracting a 2 dimensional array from a 3 dimensional matrix.

use squeeze, a = squeeze(yourmatrix(1,:,:)) first row from all pages. I suggest reading the doc page of squeeze.

Extracting a 2 dimensional array from a 3 dimensional matrix.

use squeeze, a = squeeze(yourmatrix(1,:,:)) first row from all pages. I suggest reading the doc page of squeeze.

2 years ago | 1

Answered

Matlab R2015b-->R2017a

Download and install. You can also keep multiple versions on the same PC. Download link: <https://www.mathworks.com/downloads...

Matlab R2015b-->R2017a

Download and install. You can also keep multiple versions on the same PC. Download link: <https://www.mathworks.com/downloads...

2 years ago | 0

Answered

How to collect a series of value in my code then arrange them into a new array?

Firstly, you could eliminate the for loop and if statements in your code by using simple indexing. t=0:0.05:5; T = 1...

How to collect a series of value in my code then arrange them into a new array?

Firstly, you could eliminate the for loop and if statements in your code by using simple indexing. t=0:0.05:5; T = 1...

2 years ago | 0

Answered

How to make an array with specific matrix values

I assume you have a matrix of two columns, A = [1 2 3 4 5 6 7 8 9 10;2 2 3 3 4 4 3 3 2 2]'; A(diff(A(:,2))==0,1) ans ...

How to make an array with specific matrix values

I assume you have a matrix of two columns, A = [1 2 3 4 5 6 7 8 9 10;2 2 3 3 4 4 3 3 2 2]'; A(diff(A(:,2))==0,1) ans ...

2 years ago | 0

Answered

Mean value every 60 rows

*Simpler:* No need to use loops/arrayfun or cellfun at all. Simpler solution is to use just reshape with mean, cc = resha...

Mean value every 60 rows

*Simpler:* No need to use loops/arrayfun or cellfun at all. Simpler solution is to use just reshape with mean, cc = resha...

2 years ago | 0

Answered

What is wrong with my while loop?

Comparing matrices is easier if you use |isequal| command. <https://www.mathworks.com/help/matlab/ref/isequal.html> You sh...

What is wrong with my while loop?

Comparing matrices is easier if you use |isequal| command. <https://www.mathworks.com/help/matlab/ref/isequal.html> You sh...

2 years ago | 0

Answered

How to change the middle line width in barh plot?

You don't need to change the axis line thickness but simply plot a vertical line like, plot([0 0],[0 10],'k','linewidth',3)

How to change the middle line width in barh plot?

You don't need to change the axis line thickness but simply plot a vertical line like, plot([0 0],[0 10],'k','linewidth',3)

2 years ago | 0

| accepted

Answered

Prompt to import data from csv file with specific column vectors

One of the things I love about MATLAB is its extensive documentation. Here's a link for you <https://www.mathworks.com/help/m...

Prompt to import data from csv file with specific column vectors

One of the things I love about MATLAB is its extensive documentation. Here's a link for you <https://www.mathworks.com/help/m...

2 years ago | 0

Answered

shift matrix from a specific row

Pretty much the same answer as Geoff Hayes' but just with a handle, add_row = @(ind,a) [a(1:ind-1,:); zeros(1,size(a,2)); ...

shift matrix from a specific row

Pretty much the same answer as Geoff Hayes' but just with a handle, add_row = @(ind,a) [a(1:ind-1,:); zeros(1,size(a,2)); ...

2 years ago | 0

Answered

Proper use of regexprep

use the |^| operator. It should simply be, s2 = regexprep(s1,'[^aeiou]','') documentation explains it clearly here: <http...

Proper use of regexprep

use the |^| operator. It should simply be, s2 = regexprep(s1,'[^aeiou]','') documentation explains it clearly here: <http...

2 years ago | 0

| accepted

Answered

select 2 rows in a (n,m) matrix

I suppose you want to randomly sample 1,2 or 3 rows from your matrix. A = rand(10); % example noRows = 1; A_sample = A(r...

select 2 rows in a (n,m) matrix

I suppose you want to randomly sample 1,2 or 3 rows from your matrix. A = rand(10); % example noRows = 1; A_sample = A(r...

2 years ago | 0

Answered

how to remove duplicates from a mateix ?

use unique(your_matrix,'rows') read the documentation: <https://de.mathworks.com/help/matlab/ref/unique.html>

how to remove duplicates from a mateix ?

use unique(your_matrix,'rows') read the documentation: <https://de.mathworks.com/help/matlab/ref/unique.html>

2 years ago | 1

| accepted

Answered

Create Legend From Array

Without a loop maybe, legendCell = strcat('N=',string(num2cell(1:nN))) and then as you might know, legend(legendCell)...

Create Legend From Array

Without a loop maybe, legendCell = strcat('N=',string(num2cell(1:nN))) and then as you might know, legend(legendCell)...

2 years ago | 3

Answered

How to match from 2 square brackets till end using regular expression

Something like this, s1 = '{[1,2],[3,4],[[5,6],[7,8]]}'; s2 = '[9,10],[11,12]'; s3 = regexprep(s1,'(?<=\[)(\[)[^...

How to match from 2 square brackets till end using regular expression

Something like this, s1 = '{[1,2],[3,4],[[5,6],[7,8]]}'; s2 = '[9,10],[11,12]'; s3 = regexprep(s1,'(?<=\[)(\[)[^...

2 years ago | 1

| accepted

Answered

How to Merge two graphs?

You can use |hold| to hold the current graph on the plot and keep plotting on the same axis unless you remove the hold. <http...

How to Merge two graphs?

You can use |hold| to hold the current graph on the plot and keep plotting on the same axis unless you remove the hold. <http...

2 years ago | 0

Answered

Undeclared function or variable.

Your condition |div >= i && div < i + 1| probably never becomes true and so |class_pointb| is never defined. This is why initial...

Undeclared function or variable.

Your condition |div >= i && div < i + 1| probably never becomes true and so |class_pointb| is never defined. This is why initial...

2 years ago | 1

| accepted

Answered

Raise the zeros in the vector up

Something like this, v = [5 8 0 7 9 0 3] ind = v==0; v = [v(ind) v(~ind)]

Raise the zeros in the vector up

Something like this, v = [5 8 0 7 9 0 3] ind = v==0; v = [v(ind) v(~ind)]

2 years ago | 0

| accepted