845 total contributions since 2013

General interest: interdisciplinary approaches to complex problems (in particular mixing Mathematics, Physics, and Computer science).

Answered

How to write cell array into a csv file

To write the data in C to a CSV file. Use “writetable” in combination with the “cell2table” function. % Convert cell to a tabl...

How to write cell array into a csv file

To write the data in C to a CSV file. Use “writetable” in combination with the “cell2table” function. % Convert cell to a tabl...

3 months ago | 21

| accepted

Answered

How to slice each string in a string array without using for loop

If you favor performance over readability/maintainability, you can build an approach around the following: buffer = vertcat(...

How to slice each string in a string array without using for loop

If you favor performance over readability/maintainability, you can build an approach around the following: buffer = vertcat(...

5 months ago | 4

| accepted

Answered

How to retrieve z value from surf plot given x and y?

Interpolate with |INTERP2| : <https://www.mathworks.com/help/matlab/ref/interp2.html> where |Xq| and |Yq| are defined using t...

How to retrieve z value from surf plot given x and y?

Interpolate with |INTERP2| : <https://www.mathworks.com/help/matlab/ref/interp2.html> where |Xq| and |Yq| are defined using t...

5 months ago | 0

| accepted

Answered

Writing a loop to calculate a seasonal cycle and then plot the seasonal cycle?

Where is |t| defined? In addition, |month_mean| is your intermediary variable; you want to plot either |seasonal_cycle| or |s_cy...

Writing a loop to calculate a seasonal cycle and then plot the seasonal cycle?

Where is |t| defined? In addition, |month_mean| is your intermediary variable; you want to plot either |seasonal_cycle| or |s_cy...

1 year ago | 0

Answered

How to read large text data into matlab

If you have enough RAM for this, the following could run a little faster. It is way less versatile than Per's solution though, a...

How to read large text data into matlab

If you have enough RAM for this, the following could run a little faster. It is way less versatile than Per's solution though, a...

1 year ago | 1

| accepted

Answered

How can I create a matrix with the values of the elements is a function of the indices?

Not sure that I understand. If you wanted to create a rectangular array whose elements are a the result of some arithmetic opera...

How can I create a matrix with the values of the elements is a function of the indices?

Not sure that I understand. If you wanted to create a rectangular array whose elements are a the result of some arithmetic opera...

1 year ago | 0

| accepted

Answered

Strfind to contain complex pattern

Here is an approach: str = 'John played volleyball. I love Anna. Are you there?' ; buffer = strtrim( strsplit( str, {'....

Strfind to contain complex pattern

Here is an approach: str = 'John played volleyball. I love Anna. Are you there?' ; buffer = strtrim( strsplit( str, {'....

1 year ago | 0

| accepted

Answered

Rearrange cell content by groups

Hi |dpb|, Assuming that you have a cell array (and that you are using this _table type of output_ just for a _display purpose...

Rearrange cell content by groups

Hi |dpb|, Assuming that you have a cell array (and that you are using this _table type of output_ just for a _display purpose...

1 year ago | 0

Question

Solving A{k} * x + b = 0 for large numbers of A{k} with same structure/filling.

Dear all, I am trying to improve the efficiency of solving |A{k}*x+b=0| for |x|, that I currently solve using the...

1 year ago | 2 answers | 0

Question

Should I (and how to) avoid "forests" of listeners in nested OOP structure.

Dear all, I never used more than the basics of events and listeners, and I could benefit from the input of ...

1 year ago | 0 answers | 0

Question

Dynamic superclass name in call to superclass method.

Dear all, In a particular context, I could benefit from being able to use _"dynamic superclass naming"_ in calls...

1 year ago | 0 answers | 1

Question

Error management in OOP framework.

Dear all, I am trying to implement an error management mechanism that allows building very detailed error r...

1 year ago | 1 answer | 1

Answered

How to vertcat 100 matrices ?

If they are stored in cell array |M|: Mvcat = vertcat( M{:} ) ; where |M{:}| is what we call a _comma separated list_ (CS...

How to vertcat 100 matrices ?

If they are stored in cell array |M|: Mvcat = vertcat( M{:} ) ; where |M{:}| is what we call a _comma separated list_ (CS...

1 year ago | 1

| accepted

Answered

print leading and trailing zeros into text file

>> dec2hex(195112160, 8) ans = '0BA12CE0'

print leading and trailing zeros into text file

>> dec2hex(195112160, 8) ans = '0BA12CE0'

1 year ago | 0

| accepted

Answered

Finding and saving identical rows in a matrix

Alternatively: [~, ~, ic] = unique( A(:,1:2), 'rows' ) ; groups = splitapply( @(x){x}, A, ic ) ; produces groups = ...

Finding and saving identical rows in a matrix

Alternatively: [~, ~, ic] = unique( A(:,1:2), 'rows' ) ; groups = splitapply( @(x){x}, A, ic ) ; produces groups = ...

1 year ago | 1

| accepted

Answered

How extract sub matrix without zeros from a big matrix

Here is an example; we first build a test data set: >> N = randi( 10, 10, 4 ) ; >> for k = 1 : 10, N(k,1+randi(3,1):end) =...

How extract sub matrix without zeros from a big matrix

Here is an example; we first build a test data set: >> N = randi( 10, 10, 4 ) ; >> for k = 1 : 10, N(k,1+randi(3,1):end) =...

1 year ago | 0

| accepted

Answered

How to remove repeating elments from a matrix?

Almost, the idea was correct but you were not working on the correct dimension. Also, sorting the input array vertically makes c...

How to remove repeating elments from a matrix?

Almost, the idea was correct but you were not working on the correct dimension. Also, sorting the input array vertically makes c...

1 year ago | 0

| accepted

Answered

sum of matrix omitting one dimension

Here is one way, but there is probably a simpler approach: buffer = arrayfun(@(k) permute(KL, circshift(1:ndims(KL), k-1)), ...

sum of matrix omitting one dimension

Here is one way, but there is probably a simpler approach: buffer = arrayfun(@(k) permute(KL, circshift(1:ndims(KL), k-1)), ...

1 year ago | 0

Answered

Split array into cell arrays of different size

>> seqs = mat2cell( A, 1, diff( [strfind(A, [5,19]), numel(A)+1] )) seqs = 1×5 cell array {1×4 double} {1×3 doub...

Split array into cell arrays of different size

>> seqs = mat2cell( A, 1, diff( [strfind(A, [5,19]), numel(A)+1] )) seqs = 1×5 cell array {1×4 double} {1×3 doub...

1 year ago | 0

Answered

Find if two sparse matrix have 1 in same position

Do you need something along this line? % - Build small test case. A = sprand( 4, 5, 0.5 ) > 0 ; % 4x5 sparse. B =...

Find if two sparse matrix have 1 in same position

Do you need something along this line? % - Build small test case. A = sprand( 4, 5, 0.5 ) > 0 ; % 4x5 sparse. B =...

1 year ago | 0

| accepted

Answered

How to import Text File with 2 different Delimiters (how to organize header data and numeric data)

You may not need to use header information for parsing your file. Look at this example (applied to |data.txt| attached): ...

How to import Text File with 2 different Delimiters (how to organize header data and numeric data)

You may not need to use header information for parsing your file. Look at this example (applied to |data.txt| attached): ...

1 year ago | 0

Answered

Any tips for bsxfun and repeated calculation?

If you have MATLAB R2016b or above, BSXFUN was replaced by automatic expansion and you can do it as follows: >> D = repmat( ...

Any tips for bsxfun and repeated calculation?

If you have MATLAB R2016b or above, BSXFUN was replaced by automatic expansion and you can do it as follows: >> D = repmat( ...

1 year ago | 0

| accepted

Answered

sum along data with different steps

Interestingly, the following seems to produce what you are looking for: >> expandSum = @(x,n) sum(reshape(cell2mat(arrayfun(...

sum along data with different steps

Interestingly, the following seems to produce what you are looking for: >> expandSum = @(x,n) sum(reshape(cell2mat(arrayfun(...

1 year ago | 1

| accepted

Answered

How to read the given type of data from text file as an input to my further matlab code

Is the following working? data = reshape(sscanf(strrep(fileread('MyData.txt'), ':', ' '), '%f'), 310, []).' ;

How to read the given type of data from text file as an input to my further matlab code

Is the following working? data = reshape(sscanf(strrep(fileread('MyData.txt'), ':', ' '), '%f'), 310, []).' ;

1 year ago | 0

Answered

cell consisting letters and numbers to matrix double

>> C = {'ABC8', 'CAD90.87', 'ZED40'} ; >> C2 = cellfun( @(s)s(4:end), C, 'UniformOutput', false ) ; >> str2double( C2 )...

cell consisting letters and numbers to matrix double

>> C = {'ABC8', 'CAD90.87', 'ZED40'} ; >> C2 = cellfun( @(s)s(4:end), C, 'UniformOutput', false ) ; >> str2double( C2 )...

1 year ago | 0

Answered

Read row x to row y in a textfile

Is the following working? [T1,PSA1]=textread('FFC_M7_1.txt', '%f %f %*s %*s','headerlines',32781); or content = f...

Read row x to row y in a textfile

Is the following working? [T1,PSA1]=textread('FFC_M7_1.txt', '%f %f %*s %*s','headerlines',32781); or content = f...

1 year ago | 1

| accepted

Answered

How do i count a certain class of numbers in a 100x100 matrix?

>> sum(~imag(za(:))) ans = 8627

How do i count a certain class of numbers in a 100x100 matrix?

>> sum(~imag(za(:))) ans = 8627

1 year ago | 0

| accepted

Answered

When was 'tokenize' dropped from regexprep?

R14 You'll have to write a book about regexp after all these threads ;-) *EDIT:* found it mentioned in the PDF release not...

When was 'tokenize' dropped from regexprep?

R14 You'll have to write a book about regexp after all these threads ;-) *EDIT:* found it mentioned in the PDF release not...

1 year ago | 1

| accepted

Solved

Check if number exists in vector

Return 1 if number _a_ exists in vector _b_ otherwise return 0. a = 3; b = [1,2,4]; Returns 0. a = 3; b = [1,...

1 year ago

Answered

Text Extraction and retrieval

Here is another approach based on pattern matching: >> data = regexp(fileread('data.txt'), '(?<=<P[^>]+>\s*)[\w ]+', 'match'...

Text Extraction and retrieval

Here is another approach based on pattern matching: >> data = regexp(fileread('data.txt'), '(?<=<P[^>]+>\s*)[\w ]+', 'match'...

1 year ago | 2