Answered

Regionprops returning "wrong" axis lengths

That's because all the ellipse properties are not designed for hollow shapes. Matlab is trying to fit an ellipse just to the 'on...

Regionprops returning "wrong" axis lengths

That's because all the ellipse properties are not designed for hollow shapes. Matlab is trying to fit an ellipse just to the 'on...

19 hours ago | 1

| accepted

Answered

Average in a 1D array

Assumming the number of elements of the vectors is a multiple of n, reshape the vector in columns of n rows and take the mean ac...

Average in a 1D array

Assumming the number of elements of the vectors is a multiple of n, reshape the vector in columns of n rows and take the mean ac...

19 hours ago | 1

Answered

structure contains multiple cells with different variables in them I would like to remove variables not present in all cells

%identify common fields commonfields = fieldnames(data{1}); for cidx = 2:numel(data) commonfields = intersect(commonfield...

structure contains multiple cells with different variables in them I would like to remove variables not present in all cells

%identify common fields commonfields = fieldnames(data{1}); for cidx = 2:numel(data) commonfields = intersect(commonfield...

19 hours ago | 0

| accepted

Answered

Replace letters in matrix

I would be wary of using regexprep as per Walter's code for that. It relies on the fact that replacements are attempted in the o...

Replace letters in matrix

I would be wary of using regexprep as per Walter's code for that. It relies on the fact that replacements are attempted in the o...

21 hours ago | 0

Answered

accessing large MAT file

See the limitations section of matfile to see what it can and can't do. In particular, the granularity of matfile is typically a...

accessing large MAT file

See the limitations section of matfile to see what it can and can't do. In particular, the granularity of matfile is typically a...

1 day ago | 0

Answered

Finding values within a matrix

It appears that you are building your code from bits you've asked or found without really understanding how it works. In particu...

Finding values within a matrix

It appears that you are building your code from bits you've asked or found without really understanding how it works. In particu...

1 day ago | 0

| accepted

Answered

How to parse a table (in a text file) into matlab cell array where we have some missing values?

Your file appears to have fixed width fields. the easiest way to import such files is with FixedWidthImportOptions, e.g.: opts ...

How to parse a table (in a text file) into matlab cell array where we have some missing values?

Your file appears to have fixed width fields. the easiest way to import such files is with FixedWidthImportOptions, e.g.: opts ...

2 days ago | 0

Answered

[Solved] How can I make my output into a 2D char array instead of separate answers?

My idea was to concatenate each line, but it doesn't seem possible without resetting Well, you're doing assignment which indeed...

[Solved] How can I make my output into a 2D char array instead of separate answers?

My idea was to concatenate each line, but it doesn't seem possible without resetting Well, you're doing assignment which indeed...

5 days ago | 1

Answered

Montage from a cell array of image file names

Note that you can look at the code of montage to see what it does. As Praveen commented, it's not clear what final image size yo...

Montage from a cell array of image file names

Note that you can look at the code of montage to see what it does. As Praveen commented, it's not clear what final image size yo...

5 days ago | 0

| accepted

Answered

How to save structure inside a structure in .mat file?

If S is indeed a structure as you have defined, then save('data', 'S'); does indeed save the whole structure as one structure ...

How to save structure inside a structure in .mat file?

If S is indeed a structure as you have defined, then save('data', 'S'); does indeed save the whole structure as one structure ...

5 days ago | 0

Answered

Taking in a function as an argument

Seems clear enough: Error in bisekt (line 14) bisekt(m, x2) Within bisekt, you call the function again, this time...

Taking in a function as an argument

Seems clear enough: Error in bisekt (line 14) bisekt(m, x2) Within bisekt, you call the function again, this time...

5 days ago | 0

| accepted

Answered

while loops not work using randsample

Maybe if you used proper indenting in your code, you'd see the silliness of it: %... code irrelevant while eq1 < 1 && eq2 > 1 ...

while loops not work using randsample

Maybe if you used proper indenting in your code, you'd see the silliness of it: %... code irrelevant while eq1 < 1 && eq2 > 1 ...

5 days ago | 1

Answered

How to pass a method as a function handle

Can't tell you why it doesn't work as you have written, I suspect that this has to do with how the . operator is implemented in ...

How to pass a method as a function handle

Can't tell you why it doesn't work as you have written, I suspect that this has to do with how the . operator is implemented in ...

5 days ago | 0

Answered

How to remove user-defined objects from memory?

Note that this has nothing to do with objects. You don't seem to be understanding cell arrays. Your B is a cell array. A cell a...

How to remove user-defined objects from memory?

Note that this has nothing to do with objects. You don't seem to be understanding cell arrays. Your B is a cell array. A cell a...

6 days ago | 1

| accepted

Answered

Concatenate cells leaving columns/rows empty

Do you mean this: c = {}; %or better if you know the final size: %c = cell(1, 3); c(1, [1 3]) = [a,b]; %put a at column 1 a...

Concatenate cells leaving columns/rows empty

Do you mean this: c = {}; %or better if you know the final size: %c = cell(1, 3); c(1, [1 3]) = [a,b]; %put a at column 1 a...

6 days ago | 0

| accepted

Answered

Dynamic/global function definition

You've done it already! Instead of using setfunc in dynfunc to apply it to X, simply return it out of dynfunc, so it can be use...

Dynamic/global function definition

You've done it already! Instead of using setfunc in dynfunc to apply it to X, simply return it out of dynfunc, so it can be use...

6 days ago | 0

| accepted

Answered

Separating Multiple Columns of Data Based on a Value in One Column

While you could indeed explicitly separate the data per ROI, you probably don't need to. Matlab has several functions that allow...

Separating Multiple Columns of Data Based on a Value in One Column

While you could indeed explicitly separate the data per ROI, you probably don't need to. Matlab has several functions that allow...

6 days ago | 0

Answered

How can I use switch case function to get decimal numbers?

I'm curious if you understand what that num2cell(-10.0:0) actually do in the case statement? If you don't and it's something you...

How can I use switch case function to get decimal numbers?

I'm curious if you understand what that num2cell(-10.0:0) actually do in the case statement? If you don't and it's something you...

6 days ago | 0

| accepted

Answered

How to get more decimal places in my output?

Nothing is ignored. Moreover, note that there is a difference between the actual value of a number and the way it is displayed. ...

How to get more decimal places in my output?

Nothing is ignored. Moreover, note that there is a difference between the actual value of a number and the way it is displayed. ...

7 days ago | 1

| accepted

Answered

Calculate table column with a loop

As usual with matlab, it's simpler without a loop result = diff(table2array(yourtable), [], 2); %difference between consecutiv...

Calculate table column with a loop

As usual with matlab, it's simpler without a loop result = diff(table2array(yourtable), [], 2); %difference between consecutiv...

7 days ago | 1

Answered

How can i do the summation of every row?

Guessing at what you're trying to do from your loop code: Data{:, 111} = sum(Data{:, 83:110} >= 0, 2); It doesn't look like yo...

How can i do the summation of every row?

Guessing at what you're trying to do from your loop code: Data{:, 111} = sum(Data{:, 83:110} >= 0, 2); It doesn't look like yo...

7 days ago | 0

Answered

How can I contruct a matrix with elements set to 1 given by the index position in another matrix?

coloffsets = [2,3,4;3,4,5;1,2,3] result = zeros(size(coloffsets, 1), 1+max(coloffsets(:))); result(sub2ind(size(result), rep...

How can I contruct a matrix with elements set to 1 given by the index position in another matrix?

coloffsets = [2,3,4;3,4,5;1,2,3] result = zeros(size(coloffsets, 1), 1+max(coloffsets(:))); result(sub2ind(size(result), rep...

8 days ago | 0

| accepted

Answered

How can I extract values from a second column after three repeating values in the first column?

One way: x = [1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 1]; y = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19...

How can I extract values from a second column after three repeating values in the first column?

One way: x = [1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 1]; y = [1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19...

8 days ago | 0

Answered

Compare two matrix row by row and check if at least one row is different, enter the if loop

if is not a looping statement, it's a branching statement. loops are started by for or while. Anyway, if any(ismember(A, B, 'r...

Compare two matrix row by row and check if at least one row is different, enter the if loop

if is not a looping statement, it's a branching statement. loops are started by for or while. Anyway, if any(ismember(A, B, 'r...

8 days ago | 1

| accepted

Answered

Help me make my code faster

Unless I'm misreading your code, you're simply computing the histogram of the rows of A. So, assuming that A is made up solely o...

Help me make my code faster

Unless I'm misreading your code, you're simply computing the histogram of the rows of A. So, assuming that A is made up solely o...

8 days ago | 1

| accepted

Answered

How to show bin counts' percentage values in Histogram2 tile plot?

It's all explained in the doc of histogram2. You don't even have to make the percentage calculation yourself, histogram2 will do...

How to show bin counts' percentage values in Histogram2 tile plot?

It's all explained in the doc of histogram2. You don't even have to make the percentage calculation yourself, histogram2 will do...

9 days ago | 0

Answered

How to convert string or chars to string arrays withing for loop?

An easy way, with no loop, a bit similar to Stephan's answer: %demo data: in = char(randi(double('AZ'), 1, 28)) %random strin...

How to convert string or chars to string arrays withing for loop?

An easy way, with no loop, a bit similar to Stephan's answer: %demo data: in = char(randi(double('AZ'), 1, 28)) %random strin...

9 days ago | 2

Answered

"Scaling" a matrix of matrices into a supermatrix

One way: blocksize = [2, 2]; %size of blocks along rows/columns numrepeat = [2, 2]; %number of repeat of each block along ro...

"Scaling" a matrix of matrices into a supermatrix

One way: blocksize = [2, 2]; %size of blocks along rows/columns numrepeat = [2, 2]; %number of repeat of each block along ro...

9 days ago | 2

Answered

find the max value in an array from a selection of elements corresponding to non unique items in another array

Note: For such large arrays, it is better to attach your data as a mat file rather than copy/pasting the content in the question...

find the max value in an array from a selection of elements corresponding to non unique items in another array

Note: For such large arrays, it is better to attach your data as a mat file rather than copy/pasting the content in the question...

9 days ago | 0

Answered

i want to make a user input file where the matrix would be loaded into matlab

Just make it a .m file (and remove the %). Of course, don't use A both as the constant 30 and as the name of a matrix. You can ...

i want to make a user input file where the matrix would be loaded into matlab

Just make it a .m file (and remove the %). Of course, don't use A both as the constant 30 and as the name of a matrix. You can ...

9 days ago | 0