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

1年以上 前 | 2

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

1年以上 前 | 0

| 採用済み

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

1年以上 前 | 1

MATLAB Answers Wish-list #4 (and bug reports)
Rep. points should be convertible to bitcoin!

1年以上 前 | 1

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

1年以上 前 | 0

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

1年以上 前 | 1

| 採用済み

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

1年以上 前 | 0

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

1年以上 前 | 0

| 採用済み

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

1年以上 前 | 1

| 採用済み

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

1年以上 前 | 1

| 採用済み

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

1年以上 前 | 0

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

1年以上 前 | 0

| 採用済み

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

1年以上 前 | 0

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

1年以上 前 | 0

| 採用済み

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

1年以上 前 | 1

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

1年以上 前 | 0

| 採用済み

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

1年以上 前 | 1

| 採用済み

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

1年以上 前 | 1

| 採用済み

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

1年以上 前 | 0

| 採用済み

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

1年以上 前 | 1

| 採用済み

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

1年以上 前 | 0

| 採用済み

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

1年以上 前 | 3

How to overlay randomized point grid on photo?
I = imread( 'MyImage.png' ) ; x = rand( 1, 50 ) * size( I, 2 ) ; y = rand( 1, 50 ) * size( I, 1 ) ; imshow( I ) ; h...

1年以上 前 | 0

Deleting Nonzero elements in each row
Here is one way: >> A A = 0 0 5 5 4 1 0 1 3 0 4 2 0 0 3...

1年以上 前 | 0

How to group rows of data into a cell of a cell array?
Here is one way. We start by building a fake data set: >> A = [rand(10,3), randi(2,10,3)] A = 0.7513 0.8407 0.3...

1年以上 前 | 1

| 採用済み

How i can remove HTML tags
content = regexprep( content, '<.*?>', '' ) ; *EDIT:* and the following thread just came back, with Sean mentioning the Text...

1年以上 前 | 1

calling a function in another function by changing only few input arguments
If you are in another function where variables with the same names are defined (e.g. because they are arguments of the function)...

1年以上 前 | 0

| 採用済み

how to convert collumn matrix (nxn) into another matrix of (mxn) type .
Difficult to answer with that little detail.. Maybe: M = reshape( v, n, n ) ; or M = reshape( v, n, [] ) ; with a...

1年以上 前 | 0

Accessing the string elements
Here is one way, as string arrays are "iterable". continents = ["America", "Europe"] ; countries.America = ["USA", "Bra...

1年以上 前 | 1

| 採用済み

Export Data from a Structure which contains double timeseries data to Excel ... Example Data Provided...
Here is one way if you want to create two worksheets "Left" and "Right" in the same workbook, with 21 column per sheet for time ...

1年以上 前 | 2

| 採用済み