Community Profile

photo

Paolo


Actif depuis 2018

Statistiques

All
  • First Review
  • 3 Month Streak
  • Knowledgeable Level 4
  • Thankful Level 1
  • Solver
  • First Answer

Afficher les badges

Content Feed

Afficher par

A répondu
How to slice each string in a string array without using for loop
str2double(regexp(celldata,'(?<=-)\d+(?=-)','match','once')) ans = 12 11 9

plus de 5 ans il y a | 1

A répondu
how do I extract part of a cell of string values?
You could loop over it: arr = {"201808250100","201808250104"} f=cellstr(arr); cellfun(@(x) x(end-3:end),f,'un',0) ...

plus de 5 ans il y a | 0

A répondu
Import .txt data into CELL ARRAY
Try something like this: raw = fileread('mytextfile.txt'); [~,tok]=regexp(raw,'([A-Z][a-z]+).*?(\[.*?(?=[ ,][A-Z}]))','m...

plus de 5 ans il y a | 0

A répondu
returning differences between two matrices
You can use <https://www.mathworks.com/help/matlab/ref/setdiff.html setdiff>: [~,ia] = setdiff(A,B)

plus de 5 ans il y a | 0

A répondu
How do I find the biggest difference in an array?
>> A=[62 1 0]; >> max(reshape((diff(perms(A))),1,[])) 62 >> A = [62, 10, 18, 100, 4, -300]; >> max(reshape((diff...

plus de 5 ans il y a | 1

A répondu
How to get row indices of names ends with specified common substring
rowIdx=find(endsWith(names,pattern)) For previous versions: rowIdx=find(cellfun(@(x) strcmp(x(end-1:end),'_A'),names))...

plus de 5 ans il y a | 1

| A accepté

A répondu
problem with coding cumsum statement
A few things here. First of all, you can't apply cumsum because, as MATLAB is telling you, the data is not numeric. When you are...

plus de 5 ans il y a | 0

A répondu
How to create a vector from a loop?
Simply preallocate and then write to the column vector: v = zeros(size(M,2),1); for i = 1:size(M,2) v(i,1)= (M(i,3))-...

plus de 5 ans il y a | 1

| A accepté

A répondu
extracting numbers from a cell
d = SP{:} >>[d{1}{:}] 1 4 5 6

plus de 5 ans il y a | 0

| A accepté

A répondu
Keep specific column variables and delete others?
Var1 = {'Sanchez';'Johnson';'Li';'Diaz';'Brown'}; Var2 = [38;43;38;40;49]; Var3 = logical([1;0;1;0;1]); T = table(V...

plus de 5 ans il y a | 1

| A accepté

A répondu
how to extract certain data points from a long array based on certain criteria
veh_velo = [0,0,1,3,7,9,11,15,18,20,19,19]; accel_pedal = [0,0,2,4,6,9,10,11,12,13,13]; accel_pedal(veh_velo >= ...

plus de 5 ans il y a | 1

| A accepté

A répondu
listing folders in directory with specific strings
You can work around it with a dos command: [status,cmdout] = dos("dir *") list = regexp(cmdout,'\d{6}-[A-Za-z]+','match');...

plus de 5 ans il y a | 0

| A accepté

A répondu
How can I define a variable with a name based on an input?
If I am understanding your question correctly, you can use: ship_name = input('Name of the ship: ','s'); assignin('base'...

plus de 5 ans il y a | 1

| A accepté

A répondu
Extract Variables from mixed string
You can use: mystring = '# Message: onset_pic1_8.png'; matches = regexp(mystring,'\d|[a-z]+(?=_|\d)','match') >>mat...

plus de 5 ans il y a | 2

A répondu
How to get sum of a range
You want to use the OR operator here and not the AND. Use: nnz(v<2 | v>4)

plus de 5 ans il y a | 0

| A accepté

A répondu
how to delete row and column at a single command????????????
A(:,2:2:4) = []; A(2:2:4,:) = [];

plus de 5 ans il y a | 0

A répondu
Read data from a .txt file with two columns
If you want a cell array you can use: fileID = fopen('mytext.txt'); mydata = textscan(fileID,'%f%f','HeaderLines',1); ...

plus de 5 ans il y a | 0

A répondu
Problem 10 of MATLAB cody challenge
You can use: all(diff(x)>0)

plus de 5 ans il y a | 0

A répondu
How to clear out rows of zeros in a matrix?
Let a be your matrix: a(a(:,1)==0,:) = [];

plus de 5 ans il y a | 0

| A accepté

A répondu
converting cells with strings inside cells into strings inside cells
cellfun(@(x) regexp(x,'(?<=@)(.*)(?=@)','match'),array_of_strings) Or cellfun(@(x) regexp(x,'(?<=@)(.*)(?=@)','tokens','...

plus de 5 ans il y a | 1

| A accepté

A répondu
How to plot the occurency of an element?
For the vector a you specified period should be 1:8. Use: period = [1:8]; a = [1 1 1 2 3 3 6 6 6 6 6 7 8 8]; n = histcou...

plus de 5 ans il y a | 0

| A accepté

A répondu
If I have a matrix My matrix is: BB = [-1 5 6;4 -3 2;5 6 -7]. How to print only positive values using a while loop?
>> BB(BB>0)' ans = 4 5 5 6 6 2 if you must use a loop: ii = 1; BB = [-1 5 6;4 -3 2; ...

plus de 5 ans il y a | 0

| A accepté

A répondu
How do I count the number of new occurrences of a number in an array?
nnz(diff([0 (x==1)])==1)

plus de 5 ans il y a | 1

A répondu
How to filter out rows with NaNs from one variable and the same rows from another variable without NaNs.
indx = isnan(Y); Y(indx) = []; X(indx,:) = [];

plus de 5 ans il y a | 0

A répondu
Convert serial number dates to month and year
mydate = datetime(736473,'ConvertFrom','datenum','Format','yyyy-MM')

plus de 5 ans il y a | 1

| A accepté

A répondu
Accessing multiple logical array indexing results at the same time
If I am understanding correctly the following code should solve your problem: test = magic(4); equalToTwo = find(test == 2...

plus de 5 ans il y a | 0

| A accepté

A répondu
how can i count a cell in a randi vector
histcounts(randi(4,1,50)) The output of the function is the occurrences of numbers one to four respectively.

plus de 5 ans il y a | 0

A répondu
Why does can't I assign number greater than 1 to a matrix?
~eye(3) returns a logical array. You must convert it to double. Use: logicalMat = ~eye(3); myMat = double(logicalMat); m...

plus de 5 ans il y a | 0

| A accepté

A répondu
How do I find no. of instances of each value till it changes?
This can be achieved nicely with regular expressions. Capture a digit and backreference back to the same digits to find the patt...

plus de 5 ans il y a | 0

A répondu
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,'...

plus de 5 ans il y a | 0

Charger plus