Answered
How can I select rows in an array based on the values in the first row of another array?
idx = setdiff(1:size(yourarray,1),yourvector) out = yourarray(idx,:)

7 years ago | 1

| accepted

Answered
Search for an element in an array in reverse order
Use the 'last' option.

7 years ago | 0

| accepted

Answered
How to match Date and Data of different length?
>> D = zeros(1,numel(A)); >> [idx,idy] = ismember(A,B); >> D(idx) = C(idy(idx)) D = 4 0 0 5 0 0 9 0 7 3...

7 years ago | 0

| accepted

Answered
Matlab hexadecimal definition of a variable
>> a = sscanf('0x7C','%x') a = 124

7 years ago | 1

Answered
how do I index a vector with another vector without the use of a for loop
>> idx = ~reshape(repmat(belong,6,1),1,[]); % or use REPELEM. >> events(idx) ans = CYCLI BOXIN >> find(belong) ans = 1 ...

7 years ago | 0

Answered
My matlab doesn't work. what is the problem???
This is rather obfuscated code: par = 2*find(strncmpi('Parent', pvpairs(1 : 2 : end), 6)); What is its purpose? Why compare ev...

7 years ago | 0

Answered
Multiplication of a matrix with 6x6 cell.
Use an anonymous function instead: fun = @(m) m.*I2; S_dg = cellfun(fun,S_m,'uni',false);

7 years ago | 0

| accepted

Answered
Parsing table of string without looping
Rather than slow and complex string manipulation you can easily use sscanf to directly convert each string into a numeric matrix...

7 years ago | 0

| accepted

Answered
Does matlab have any function that can compare multiple numbers and return logical value zero or one?
>> F = @(varargin)isequal(varargin{:}); >> F(2,3,4) ans = 0 >> F(2,2,2) ans = 1 >> F(5,6,7,8,9,2) ans = 0 >> F(6,6,6,6,6,...

7 years ago | 1

| accepted

Answered
Why isn't my first line being plotted?
"Does anyone see anything that is prevent the regular plot from being plotted?" Here are two bugs on the first two lines: x=0:...

7 years ago | 0

| accepted

Answered
How to do multiple replacements in a cell array
>> [idx,idy] = ismember(cell1(:,2),cell2(:,1)); >> cell3 = cell1; >> cell3(idx,2) = cell2(idy(idx),2)

7 years ago | 0

| accepted

Answered
translating commands from python
The equivalent to numpy's where is to use indexing: https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-m...

7 years ago | 0

Answered
All possible combinations of an array and number
Download John D'Errico's excellent partitions function: https://www.mathworks.com/matlabcentral/fileexchange/12009-partitions-o...

7 years ago | 0

Answered
how to change a .txt file to a .mat file
"Anyone knows why this is the case?" dlmread only imports purely numeric data, which your file is not. You will have to parse ...

7 years ago | 2

| accepted

Answered
how to write values ​​to a vector and matrix by coordinates?
You don't need find, it is simpler and more efficient to use logical indexing: idx = A>1; x_new = x(idx); y_new = y(idx); B_...

7 years ago | 0

| accepted

Answered
error: Function definition is misplaced or improperly nested error?
"What could be the problem with it?" This: if ... ... function obj = bicomp1(c) Function definitions ca...

7 years ago | 0

| accepted

Answered
How do I generate 1000 random rows from an array only once, so that if I run the program again, it will still be the same set of randomly generated number previously
https://www.mathworks.com/help/matlab/math/generate-random-numbers-that-are-repeatable.html

7 years ago | 1

| accepted

Answered
Formatting .txt files as the one produced by command prompt.
Open the file in text mode: fileID = fopen('another_test.txt','wt'); % ^ you need this! and...

7 years ago | 1

| accepted

Answered
How to ignore letters in a numeric cell?
Simpler and much more efficient with sscanf: >> C = {'0.01mm';'0.02mm';'0.03mm';'0.04mm'}; >> V = sscanf([C{:}],'%fmm') V = ...

7 years ago | 1

Answered
check if values are in multiple ranges
>> a = [1,2,4,5,6]; >> val_bottom = [0,5,3,2]; >> vals_top = [5,10,8,12]; >> a(:)>=val_bottom & a(:)<=vals_top ans = 1 ...

7 years ago | 2

| accepted

Answered
Code failure on recent version of MATLAB
An empty permission string is not supported by the documentation: fopen(filename,''); % ^^ Not supported by the F...

7 years ago | 0

Answered
How do I remove redundant commas when writing a txt-file from a table?
Regular expressions make this easy (removes all trailing commas, removes the double quotes, and leaves the newlines unchanged): ...

7 years ago | 0

Answered
Assign variables while importing data
Do NOT use eval for importing data, unless you intentionally want to force yourself into writing slow, complex, buggy code. Read...

7 years ago | 1

| accepted

Answered
How to generate random number within a range?
>> 0.2+(1-0.2)*rand() ans = 0.85178

7 years ago | 0

| accepted

Answered
For loop for unequal increment
You are confusing two different ways of defining filenames. Currently you use dir to get the actual filenames from the OS, but t...

7 years ago | 0

Answered
How to split a string of digits into groups of three from right-to-left using only regular expressions?
With one regexp call (uses a lookaround assertion): >> str = '12345678'; >> regexp(str, '(^\d{1,2}(?=(\d{3})*$)|\d{3})','match...

7 years ago | 1

| accepted

Answered
Index 3D Array with 2D logical array
P = size(A,3); F = @(b,s)repmat(b,1,1,P)&reshape(ismember(1:P,s),1,1,P); % requires >=R2016b A(F(B,[1,2,3])) = A(F(B,[5,6,7]))...

7 years ago | 0

Answered
Finding three columns in one variable in another variable
I tried a simple vectorized solution of permute and sum of squares approach, but ran into "out of memory" issues: >> C = dlmrea...

7 years ago | 1

| accepted

Answered
How to extract numeric values from char
>> C = {'{"name":"rect","x":101,"y":30,"width":239,"height":244}'; '{"name":"rect","x":503,"y":88,"width":124,"height":165...

7 years ago | 1

| accepted

Answered
How to move values of matrix for 1 out of two rows?
>> M = [1,0,5,0;2,0,6,0;3,0,7,0;4,0,8,0] M = 1 0 5 0 2 0 6 0 3 0 7 0 4 0 8 0 >> M(2:2:...

7 years ago | 0

Load more