Answered

Sum in groups of ones and zeros

A possible solution: For ones: [sindx,endindx] = regexp(char(idx+'0')','1*') indx = arrayfun(@(x,y) x:y,sindx,endindx,'...

Sum in groups of ones and zeros

A possible solution: For ones: [sindx,endindx] = regexp(char(idx+'0')','1*') indx = arrayfun(@(x,y) x:y,sindx,endindx,'...

4 years ago | 0

Answered

How can I specify the file path for csvwrite to write a file to?

csvwrite('C:\Users\T4H14\Documents\myfile.csv',mydata)

How can I specify the file path for csvwrite to write a file to?

csvwrite('C:\Users\T4H14\Documents\myfile.csv',mydata)

4 years ago | 1

| accepted

Answered

regexp split at first whitespace

You may use the *once* option to split only once at the first occurrence of whitespace. splitcells = regexp(data,'\s','split...

regexp split at first whitespace

You may use the *once* option to split only once at the first occurrence of whitespace. splitcells = regexp(data,'\s','split...

4 years ago | 3

| accepted

Answered

Adapting the datetime function

You must use the correctly specifiers for 'InputFormat', *mm* for minutes and *ss* for seconds. str = "13.07.2018 09:59:30....

Adapting the datetime function

You must use the correctly specifiers for 'InputFormat', *mm* for minutes and *ss* for seconds. str = "13.07.2018 09:59:30....

4 years ago | 1

| accepted

Answered

Extract only numbers from a text file

str = 's.CircleByCenterPerimeter(center=(9.7593, 11.2643), point1=(9.8851, 11.2643))'; regexp(str,'(?<=\()-?\d+\.?\d+','match...

Extract only numbers from a text file

str = 's.CircleByCenterPerimeter(center=(9.7593, 11.2643), point1=(9.8851, 11.2643))'; regexp(str,'(?<=\()-?\d+\.?\d+','match...

4 years ago | 0

| accepted

Answered

Sorting file (from a text file) and copying file to the new folder

If I am understanding the question correctly the following should help you: fid = fopen('SubjectsID.txt') while ~feof(fid)...

Sorting file (from a text file) and copying file to the new folder

If I am understanding the question correctly the following should help you: fid = fopen('SubjectsID.txt') while ~feof(fid)...

4 years ago | 0

Answered

How to create this monotonically increasing list of numbers?

V = [1 1 2 1 2 3 1] n = 1:numel(V); L = repelem(n,V)

How to create this monotonically increasing list of numbers?

V = [1 1 2 1 2 3 1] n = 1:numel(V); L = repelem(n,V)

4 years ago | 2

| accepted

Answered

Matrixr edundant rows removal

newmatrix = oldmatrix(find(uniquetol(oldmatrix(:,1))),:)

Matrixr edundant rows removal

newmatrix = oldmatrix(find(uniquetol(oldmatrix(:,1))),:)

4 years ago | 0

| accepted

Answered

How to filter data from multiple columns in a table

No loop is necessary. Yes, you need to use strcmp for the comparison. MT= {7 3 '15' 'response1'; 7 4 '25' 'response2';...

How to filter data from multiple columns in a table

No loop is necessary. Yes, you need to use strcmp for the comparison. MT= {7 3 '15' 'response1'; 7 4 '25' 'response2';...

4 years ago | 0

| accepted

Answered

Find row in a matrix A corresponding to the row another matrix B

If I am understanding the question correctly the answer is simply: >>C = A(B==max(B),:) C = Columns 1 through 7 -...

Find row in a matrix A corresponding to the row another matrix B

If I am understanding the question correctly the answer is simply: >>C = A(B==max(B),:) C = Columns 1 through 7 -...

4 years ago | 0

| accepted

Answered

Value associate to a parameter in a text

data = fileread('mytextfile.txt'); val = regexp(data,'(?<=\s)(-?\d*\.?\d*)(?=\s|$)','match');

Value associate to a parameter in a text

data = fileread('mytextfile.txt'); val = regexp(data,'(?<=\s)(-?\d*\.?\d*)(?=\s|$)','match');

4 years ago | 0

| accepted

Answered

Extracting X Y values from a .txt file

I think the best solution in this situation is to use regular expressions. Matlab's regexp supports named capture groups, which ...

Extracting X Y values from a .txt file

I think the best solution in this situation is to use regular expressions. Matlab's regexp supports named capture groups, which ...

4 years ago | 1

Answered

How can I determine last row and pointed out in a xlsread?

You may use this <https://uk.mathworks.com/matlabcentral/fileexchange/28343-column-converter-for-excel?focused=5156839&tab=funct...

How can I determine last row and pointed out in a xlsread?

You may use this <https://uk.mathworks.com/matlabcentral/fileexchange/28343-column-converter-for-excel?focused=5156839&tab=funct...

4 years ago | 0

| accepted

Answered

Importing 'n' number of cells in xlsread while n is not constant!

n = caselist(1,1); range = strcat('B4:B',num2str(n)) [num, txt] = xlsread('S:/PLOT/PLOT.xlsx', range);

Importing 'n' number of cells in xlsread while n is not constant!

n = caselist(1,1); range = strcat('B4:B',num2str(n)) [num, txt] = xlsread('S:/PLOT/PLOT.xlsx', range);

4 years ago | 0

| accepted

Answered

How can I sum every nth row?

A = [1 2 3 4 5 6 7; 1 3 5 7 9 11 13; 2 4 6 8 10 12 14]'; [n,col] = size(A); index = 1:n; elem = [repmat(3,1,floor(n/3))];...

How can I sum every nth row?

A = [1 2 3 4 5 6 7; 1 3 5 7 9 11 13; 2 4 6 8 10 12 14]'; [n,col] = size(A); index = 1:n; elem = [repmat(3,1,floor(n/3))];...

4 years ago | 2

| accepted

Answered

What would be the way to remove duplicates for defined numbers in array?

You can use strfind for matching patterns in arrays. Read more about it <https://blogs.mathworks.com/loren/2008/09/08/finding-pa...

What would be the way to remove duplicates for defined numbers in array?

You can use strfind for matching patterns in arrays. Read more about it <https://blogs.mathworks.com/loren/2008/09/08/finding-pa...

4 years ago | 0

| accepted

Answered

How to generate all permutations of numbers if I have a number twice?

How about calling unique function after perms? data = unique(perms([1 2 2]),'rows'); data = 1 2 2 ...

How to generate all permutations of numbers if I have a number twice?

How about calling unique function after perms? data = unique(perms([1 2 2]),'rows'); data = 1 2 2 ...

4 years ago | 1

Answered

How to check number of zeros in an array?

A = nnz(~A) B = nnz(~B) C = nnz(~C) D = nnz(~D)

How to check number of zeros in an array?

A = nnz(~A) B = nnz(~B) C = nnz(~C) D = nnz(~D)

4 years ago | 1

| accepted

Answered

Replace NaN in table with a corresponding value in a different column

You have not provided your table so I'll provide an example which should help you solve your problem. I have placed some NaNs i...

Replace NaN in table with a corresponding value in a different column

You have not provided your table so I'll provide an example which should help you solve your problem. I have placed some NaNs i...

4 years ago | 0

| accepted

Answered

Read numeric data as string data from csv (table.txt) file?

You may use the %s specifier to read your data as strings. data = readtable('Table.txt','Format','%s%s');

Read numeric data as string data from csv (table.txt) file?

You may use the %s specifier to read your data as strings. data = readtable('Table.txt','Format','%s%s');

4 years ago | 0

| accepted

Answered

string from a textbox

str = '4x^3 + 5x^2 + 6x^1 + 5' num = regexp(str,'(?<!\^)(\d)','match');

string from a textbox

str = '4x^3 + 5x^2 + 6x^1 + 5' num = regexp(str,'(?<!\^)(\d)','match');

4 years ago | 1

Answered

how to find the index of the highest negative element in a two dimensional matrix?

[row,col]=find(A==min(A(A<0)))

how to find the index of the highest negative element in a two dimensional matrix?

[row,col]=find(A==min(A(A<0)))

4 years ago | 0

| accepted

Answered

Extrapolate the times of entry and exit in timetable

%Find dbuid-17 in your second column. dbuid17indx = pir_tab_night.Column1streamId==categorical({'dbuid-17'}); %Use diff f...

Extrapolate the times of entry and exit in timetable

%Find dbuid-17 in your second column. dbuid17indx = pir_tab_night.Column1streamId==categorical({'dbuid-17'}); %Use diff f...

4 years ago | 0

| accepted

Answered

how to compare string array with the names of structure's fields.

S.a = {'First field'}; S.b = {'Second field, entry 1','Second field,entry 2'}; S.c = {1,2,3}; mystring = {'a','game','m...

how to compare string array with the names of structure's fields.

S.a = {'First field'}; S.b = {'Second field, entry 1','Second field,entry 2'}; S.c = {1,2,3}; mystring = {'a','game','m...

4 years ago | 0

| accepted

Answered

reading n columns and n rows from a file

Save your .txt file as file.dat. Then use: mydata = csvread('file.dat'); [row,col]=find(ismembertol(mydata,0.1350)); n =...

reading n columns and n rows from a file

Save your .txt file as file.dat. Then use: mydata = csvread('file.dat'); [row,col]=find(ismembertol(mydata,0.1350)); n =...

4 years ago | 0

Answered

MATLAB codes to import or read multiples data and plot it on multiple images simultaneously

If I understand correctly, you want to process multiple text files which contain X,Y coordinates. Try: files = dir('*.txt');...

MATLAB codes to import or read multiples data and plot it on multiple images simultaneously

If I understand correctly, you want to process multiple text files which contain X,Y coordinates. Try: files = dir('*.txt');...

4 years ago | 0

Answered

Separating values in cell arrays

[num, txt] = xlsread('mydata.xlsx', 'B4:B11'); mylist = cellfun(@(x) str2double(regexp(x,'(\d*\.?\d*)$','match')),txt);

Separating values in cell arrays

[num, txt] = xlsread('mydata.xlsx', 'B4:B11'); mylist = cellfun(@(x) str2double(regexp(x,'(\d*\.?\d*)$','match')),txt);

4 years ago | 0

| accepted

Answered

How to show timestamps in a uitable in Matlab GUI?

f = figure; t = uitable(f,'Data',{datestr(now)},'Position',[50 200 900 70]);

How to show timestamps in a uitable in Matlab GUI?

f = figure; t = uitable(f,'Data',{datestr(now)},'Position',[50 200 900 70]);

4 years ago | 0

| accepted

Answered

count the change between a row and the next, in a column

For categorical array c chararr = cellstr(c); num = cellfun(@(x) regexp(x,'(\d)*$','match','once'), chararr,'un',0); nch...

count the change between a row and the next, in a column

For categorical array c chararr = cellstr(c); num = cellfun(@(x) regexp(x,'(\d)*$','match','once'), chararr,'un',0); nch...

4 years ago | 1

| accepted

Answered

can you help me to correct this program i write it to remove the rows who The sum of its elements is zero

For matrix a a(~sum(a,2),:) = []

can you help me to correct this program i write it to remove the rows who The sum of its elements is zero

For matrix a a(~sum(a,2),:) = []

4 years ago | 1