Answered

arrayfun with multiple inputs and a different size output

Note: I'm not familiar enough with GPU computing to know if there are some restrictions that apply. _First issue: myfunc is ...

arrayfun with multiple inputs and a different size output

Note: I'm not familiar enough with GPU computing to know if there are some restrictions that apply. _First issue: myfunc is ...

1 hour ago | 0

Answered

Best way to sort a 3-d matrix by one column?

You can't use |sortrows| on a 3D matrix. You have two options: * Use a loop and use |sortrows| on the pages: for page = ...

Best way to sort a 3-d matrix by one column?

You can't use |sortrows| on a 3D matrix. You have two options: * Use a loop and use |sortrows| on the pages: for page = ...

19 hours ago | 0

Answered

Sorting data from table

Simple: sortedtable = sortrows(yourtable, 'year', 'flowrate', {'ascend', 'descend'}) %sort ascending by year, and for iden...

Sorting data from table

Simple: sortedtable = sortrows(yourtable, 'year', 'flowrate', {'ascend', 'descend'}) %sort ascending by year, and for iden...

1 day ago | 0

Answered

converting a decimal number to its binary.

The easy way to find the binary representation of a double number in matlab: number = 753.153; %for example dec2bin(typ...

converting a decimal number to its binary.

The easy way to find the binary representation of a double number in matlab: number = 753.153; %for example dec2bin(typ...

1 day ago | 0

Answered

How can I add " " to first row and column in a cell

Adding the headers to your cell array as you require is trivial: newcellarray = [{}, compose('"%d', 1996:2014); compose('"%...

How can I add " " to first row and column in a cell

Adding the headers to your cell array as you require is trivial: newcellarray = [{}, compose('"%d', 1996:2014); compose('"%...

2 days ago | 0

| accepted

Answered

count even elements vector

Isn't it trivial? Using |sum|: sum(mod(myvec, 2) == 0) Or using |nnz|: nnz(mod(myvec, 2) == 0)

count even elements vector

Isn't it trivial? Using |sum|: sum(mod(myvec, 2) == 0) Or using |nnz|: nnz(mod(myvec, 2) == 0)

2 days ago | 0

| accepted

Answered

How to set table VariableNames from a cell?

Right, this is one case of a badly explained problem and one case of a user not really understanding the error message he's give...

How to set table VariableNames from a cell?

Right, this is one case of a badly explained problem and one case of a user not really understanding the error message he's give...

2 days ago | 0

Answered

How can I make this code run faster and what is going on in it all

Despite what the misspelled and barely understandable comment says, you can use a convolution to replace the loop Ifx = con...

How can I make this code run faster and what is going on in it all

Despite what the misspelled and barely understandable comment says, you can use a convolution to replace the loop Ifx = con...

3 days ago | 0

Answered

How to read specific data from text file between 2 lines

The proper way to do this: Your file is not a text file but an xml file. Use <https://www.mathworks.com/help/matlab/ref/xmlread....

How to read specific data from text file between 2 lines

The proper way to do this: Your file is not a text file but an xml file. Use <https://www.mathworks.com/help/matlab/ref/xmlread....

4 days ago | 0

Answered

A variable index must be a real positive integer Issue in app designer

_Could it be that the fields drop down values are empty before the data is imported?_ It's simple to check using the <https:/...

A variable index must be a real positive integer Issue in app designer

_Could it be that the fields drop down values are empty before the data is imported?_ It's simple to check using the <https:/...

4 days ago | 0

Answered

Concatenate multi dimensional matrix

Your |b = cat(1, a(:, :, i))| is incorrect and is just equivalent to |b = a(:, :, i)|. If you were to use a loop you could do it...

Concatenate multi dimensional matrix

Your |b = cat(1, a(:, :, i))| is incorrect and is just equivalent to |b = a(:, :, i)|. If you were to use a loop you could do it...

4 days ago | 1

| accepted

Answered

How to create a 1x12 matrix of only .

a = [1;2;3]; b = [3;2;1]; Two easy options: compose('%d.%d', a, b) %or compose("%d.%d", a, b) to get a string arr...

How to create a 1x12 matrix of only .

a = [1;2;3]; b = [3;2;1]; Two easy options: compose('%d.%d', a, b) %or compose("%d.%d", a, b) to get a string arr...

4 days ago | 0

Answered

How can you conform one value of one matrix to all values of another?

Assuming that the last 3 elements of the last column are a typo and are supposed to be [3; 4; 5]; [bb, aa] = ndgrid(b, a); ...

How can you conform one value of one matrix to all values of another?

Assuming that the last 3 elements of the last column are a typo and are supposed to be [3; 4; 5]; [bb, aa] = ndgrid(b, a); ...

5 days ago | 0

| accepted

Answered

How to effectively get the mean for every three consecutive outputs?

It would be useful if you used proper formatting in your question so we can see actual rows and columns. Assuming the array ...

How to effectively get the mean for every three consecutive outputs?

It would be useful if you used proper formatting in your question so we can see actual rows and columns. Assuming the array ...

5 days ago | 1

| accepted

Answered

Combine times series with different length by interpolation

I would convert your tables to <https://www.mathworks.com/help/timetables.html timetables> and <https://www.mathworks.com/help/m...

Combine times series with different length by interpolation

I would convert your tables to <https://www.mathworks.com/help/timetables.html timetables> and <https://www.mathworks.com/help/m...

5 days ago | 0

Answered

Return function the same as the inputs.

Your function makes no sense. It takes two inputs, |coef| and |knots|, and the first thing it does is discard that |knots| input...

Return function the same as the inputs.

Your function makes no sense. It takes two inputs, |coef| and |knots|, and the first thing it does is discard that |knots| input...

5 days ago | 0

Answered

Use indeces of a column to sort another column

indices = str2double(A(:, 1)); B = cell(max(indices), 1); B(indices) = A(:, 2)

Use indeces of a column to sort another column

indices = str2double(A(:, 1)); B = cell(max(indices), 1); B(indices) = A(:, 2)

5 days ago | 0

| accepted

Answered

resize and save transparent PNG file in matlab

For a start you never retrieve the transparency information so it's no wonder it's not preserved. PNG images have two ways to...

resize and save transparent PNG file in matlab

For a start you never retrieve the transparency information so it's no wonder it's not preserved. PNG images have two ways to...

5 days ago | 2

| accepted

Answered

For loop with Else statement

Your code is behaving exactly as expected. It may not do what you want but that's because you've made a mistake. The best way...

For loop with Else statement

Your code is behaving exactly as expected. It may not do what you want but that's because you've made a mistake. The best way...

5 days ago | 1

| accepted

Answered

Plotting Graph from Struct

We could have done with an explanation of what the fields of your structure actually represent. Assuming that the field |A| i...

Plotting Graph from Struct

We could have done with an explanation of what the fields of your structure actually represent. Assuming that the field |A| i...

5 days ago | 2

| accepted

Answered

Separating Matrix by Column By Pattern?

Sounds very easy: starttime = datetime(2018, 9, 10); %whatever your start is sampletime = starttime + hours(0:size(samp...

Separating Matrix by Column By Pattern?

Sounds very easy: starttime = datetime(2018, 9, 10); %whatever your start is sampletime = starttime + hours(0:size(samp...

6 days ago | 0

| accepted

Answered

Readtable For Loop for importing large quantities of csv files in to Matlab

1. Replace x = {}; by x = cell(1, numel(file)); %better name for that variable advised. How about: tables Not...

Readtable For Loop for importing large quantities of csv files in to Matlab

1. Replace x = {}; by x = cell(1, numel(file)); %better name for that variable advised. How about: tables Not...

6 days ago | 0

| accepted

Answered

Splitting Cells Contents into A Uniform Dimension

Use a <https://www.mathworks.com/help/matlab/ref/matlab.io.text.fixedwidthimportoptions.html |FixedWidthImportOptions|> object t...

Splitting Cells Contents into A Uniform Dimension

Use a <https://www.mathworks.com/help/matlab/ref/matlab.io.text.fixedwidthimportoptions.html |FixedWidthImportOptions|> object t...

6 days ago | 0

| accepted

Answered

Frequency of data occurrence using histc

I presume that your numbers are integer (otherwise, you're playing dangerous games using |unique| with floating point values), i...

Frequency of data occurrence using histc

I presume that your numbers are integer (otherwise, you're playing dangerous games using |unique| with floating point values), i...

6 days ago | 0

Answered

usage of cumprod function to write the code

cumprod([1, u-(0:n-2)]) ./ factorial(0:n-1) _edit_: actually you can replace the factorial by another cumprod which should ...

usage of cumprod function to write the code

cumprod([1, u-(0:n-2)]) ./ factorial(0:n-1) _edit_: actually you can replace the factorial by another cumprod which should ...

6 days ago | 0

| accepted

Answered

how to count the number of function calls without modifying it by inserting a counter ?

Use the <https://www.mathworks.com/help/matlab/matlab_prog/profiling-for-improving-performance.html#f9-17206 Profiler> which giv...

how to count the number of function calls without modifying it by inserting a counter ?

Use the <https://www.mathworks.com/help/matlab/matlab_prog/profiling-for-improving-performance.html#f9-17206 Profiler> which giv...

6 days ago | 1

Answered

How to add two rows of binary elements of matrix in matlab ?

Ok, you left out a lot of necessary information in your question. In particular, that your addition is performed in the <https:/...

How to add two rows of binary elements of matrix in matlab ?

Ok, you left out a lot of necessary information in your question. In particular, that your addition is performed in the <https:/...

6 days ago | 0

| accepted

Answered

How to select specific time frames from data?

pickups = readtable('uber.csv'); pickuphours =hour(pickups.pickup_datetime); filteredpickups = pickups(pickuphours >= 7 ...

How to select specific time frames from data?

pickups = readtable('uber.csv'); pickuphours =hour(pickups.pickup_datetime); filteredpickups = pickups(pickuphours >= 7 ...

6 days ago | 1

| accepted

Answered

importing xml and change to mat stuct

You're making your life more complicated than you need to. You don't need to parse the file, |xml2struct| will do that for you, ...

importing xml and change to mat stuct

You're making your life more complicated than you need to. You don't need to parse the file, |xml2struct| will do that for you, ...

6 days ago | 0

| accepted

Answered

How to avoid or delete Nan values in addtion?

If I understood correctly, C = sum(cat(3, A, B), 3, 'omitnan')

How to avoid or delete Nan values in addtion?

If I understood correctly, C = sum(cat(3, A, B), 3, 'omitnan')

6 days ago | 0