Risposto

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( ...

circa 7 anni fa | 0

| accettato

Risposto

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(...

circa 7 anni fa | 1

| accettato

Risposto

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, []).' ;

circa 7 anni fa | 0

Risposto

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 )...

circa 7 anni fa | 0

Risposto

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...

circa 7 anni fa | 1

| accettato

Risposto

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

circa 7 anni fa | 0

| accettato

Risposto

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...

circa 7 anni fa | 1

| accettato

Risolto

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,...

circa 7 anni fa

Risposto

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'...

circa 7 anni fa | 2

Risposto

Find cell containing part of a string

If you cannot assume that keywords are separated by white spaces: >> find(cellfun(@(x)~isempty(strfind(stringToCheck,x)), co...

Find cell containing part of a string

If you cannot assume that keywords are separated by white spaces: >> find(cellfun(@(x)~isempty(strfind(stringToCheck,x)), co...

circa 7 anni fa | 0

| accettato

Risposto

Square matrix with relationships among equal rows.

B = all(permute(A, [1,3,2]) == permute(A, [3,1,2]), 3) ; and if you have a version of MATLAB < R2016b: B = all(bsxfun(...

Square matrix with relationships among equal rows.

B = all(permute(A, [1,3,2]) == permute(A, [3,1,2]), 3) ; and if you have a version of MATLAB < R2016b: B = all(bsxfun(...

circa 7 anni fa | 1

Risposto

[DISCONTINUED] MATLAB Answers Wish-list #4 (and bug reports)

Rep. points should be convertible to bitcoin!

[DISCONTINUED] MATLAB Answers Wish-list #4 (and bug reports)

Rep. points should be convertible to bitcoin!

circa 7 anni fa | 1

Risposto

Sparse indexing expression is likely to be slow

When building sparse matrices using an iterative approach, it is often more efficient to build vectors of indices and values ite...

Sparse indexing expression is likely to be slow

When building sparse matrices using an iterative approach, it is often more efficient to build vectors of indices and values ite...

circa 7 anni fa | 1

Risposto

Create a method that overloads a property?

We usually do this using setters and getters. You will find plenty of doc if you google these terms, e.g. <https://www.mathworks...

Create a method that overloads a property?

We usually do this using setters and getters. You will find plenty of doc if you google these terms, e.g. <https://www.mathworks...

circa 7 anni fa | 1

| accettato

Risposto

Downloading data from txt file

Here is one way: data = textscan( fileread( 'data.txt' ), '%s' ) ; data = reshape( str2double( data{1} ), 17, [] ).' ; d...

Downloading data from txt file

Here is one way: data = textscan( fileread( 'data.txt' ), '%s' ) ; data = reshape( str2double( data{1} ), 17, [] ).' ; d...

circa 7 anni fa | 0

Risposto

Speed processing if algorithm is partitioned in well-organized minor functions

Part of programming consists in understanding where and how code can be segmented into simple self-consistent functional blocks....

Speed processing if algorithm is partitioned in well-organized minor functions

Part of programming consists in understanding where and how code can be segmented into simple self-consistent functional blocks....

circa 7 anni fa | 1

| accettato

Risposto

Comparing elements in each row of a matrix

Here is one way to do it without any loop (with MATLAB R2016b or more recent): >> AQ_z_matrix=[10000 11000 20000; 10000 1100...

Comparing elements in each row of a matrix

Here is one way to do it without any loop (with MATLAB R2016b or more recent): >> AQ_z_matrix=[10000 11000 20000; 10000 1100...

circa 7 anni fa | 1

| accettato

Risposto

Matrix Elements Re-ordering

>> B = reshape( A, 2, [] ).' B = 1 3 5 7 2 4 6 8

Matrix Elements Re-ordering

>> B = reshape( A, 2, [] ).' B = 1 3 5 7 2 4 6 8

circa 7 anni fa | 1

| accettato

Risposto

Please someone solve the error of unexpected error at x=D./2f

What is |2f|? Is this what you are trying to compute? x = D ./ (2*f) ;

Please someone solve the error of unexpected error at x=D./2f

What is |2f|? Is this what you are trying to compute? x = D ./ (2*f) ;

circa 7 anni fa | 0

Risposto

How to fill a 3D array with values calculated in a loop?

This would be one way to do it if you have MATLAB R2016b or newer: A = sum( D .* permute( d(1,:), [1, 3, 2] ), 3 ) ; % F...

How to fill a 3D array with values calculated in a loop?

This would be one way to do it if you have MATLAB R2016b or newer: A = sum( D .* permute( d(1,:), [1, 3, 2] ), 3 ) ; % F...

circa 7 anni fa | 0

| accettato

Risposto

Matlab and memory use

MATLAB default numeric type/class is "double" (for double-precision floating-point) stored on 8 bytes (= 64 bits). Your array wi...

Matlab and memory use

MATLAB default numeric type/class is "double" (for double-precision floating-point) stored on 8 bytes (= 64 bits). Your array wi...

circa 7 anni fa | 0

| accettato

Risposto

How to write a line of statement with two vector of different size using no loops

>> H2 = (n >= 0) .* sum(r.' .* p.'.^n) ; >> isequal( H2, H ) ans = logical 1 if it doesn't work, you may have a...

How to write a line of statement with two vector of different size using no loops

>> H2 = (n >= 0) .* sum(r.' .* p.'.^n) ; >> isequal( H2, H ) ans = logical 1 if it doesn't work, you may have a...

circa 7 anni fa | 0

| accettato

Risposto

How can I add normal text as well as Latex symbols on a figure axis?

This is something that I don't fully understand actually, and I'd love to get some explanation from TMW. Some times (maybe on ol...

How can I add normal text as well as Latex symbols on a figure axis?

This is something that I don't fully understand actually, and I'd love to get some explanation from TMW. Some times (maybe on ol...

circa 7 anni fa | 1

Risposto

Repeat row of a matrix

Here is one way to achieve it. If >> a = [1;2;3] ; >> B = randi( 10, 3, 2 ) B = 3 10 6 2 10 ...

Repeat row of a matrix

Here is one way to achieve it. If >> a = [1;2;3] ; >> B = randi( 10, 3, 2 ) B = 3 10 6 2 10 ...

circa 7 anni fa | 0

| accettato

Risposto

How to sort a matrix based on one index I have ?

I guess/hope that you made a mistake when you built your example of sorted |t| (that seems to be sorted according to |c=[2;1;3]|...

How to sort a matrix based on one index I have ?

I guess/hope that you made a mistake when you built your example of sorted |t| (that seems to be sorted according to |c=[2;1;3]|...

circa 7 anni fa | 1

| accettato

Risposto

Find index of first zero searching from left first column first row, then find index of first zero searching from last column last row

MATLAB stores data column first in memory. Accessing your 2D array linearly follows this structure. Evaluate >> M(:) and ...

Find index of first zero searching from left first column first row, then find index of first zero searching from last column last row

MATLAB stores data column first in memory. Accessing your 2D array linearly follows this structure. Evaluate >> M(:) and ...

circa 7 anni fa | 1

| accettato

Risposto

using find function and comparing results

Don't save regular numeric data in cell arrays, you cannot compute with them and you have to go through notation- and computatio...

using find function and comparing results

Don't save regular numeric data in cell arrays, you cannot compute with them and you have to go through notation- and computatio...

circa 7 anni fa | 1

| accettato

Risposto

Matlab Performance Question (Nested for loops vs inbuilt functions (cellfun, circshift))

Well, I got a few minutes at the airport. Try this in your comparison: tic ; s = cellfun('length', t) ; v = cumsum(s)...

Matlab Performance Question (Nested for loops vs inbuilt functions (cellfun, circshift))

Well, I got a few minutes at the airport. Try this in your comparison: tic ; s = cellfun('length', t) ; v = cumsum(s)...

circa 7 anni fa | 1

| accettato

Risposto

Why do I get "Index exceeds matrix dimensions"?

Numeric arrays cannot store arrays of two characters. Try with a cell array. Also, don't index arrays with characters but with n...

Why do I get "Index exceeds matrix dimensions"?

Numeric arrays cannot store arrays of two characters. Try with a cell array. Also, don't index arrays with characters but with n...

circa 7 anni fa | 0

| accettato

Risposto

search for elements of a vector in a matrix (without using ismember)

*EDIT:* I took 3 more minutes and I profiled a small test case (N=1e7, n=1e2). *ISMEMBER is more efficient!* Here is an alter...

search for elements of a vector in a matrix (without using ismember)

*EDIT:* I took 3 more minutes and I profiled a small test case (N=1e7, n=1e2). *ISMEMBER is more efficient!* Here is an alter...

circa 7 anni fa | 3