Answered
How can I use the split function with multiple delimiters?
>> str = 'software_logical/forIteratorSubsystem/Out1'; >> [one,two] = fileparts(str) one = software_logical/forIteratorSubsyst...

6 years ago | 1

| accepted

Answered
Simplify a string with MATLAB script
>> Eq = 'A_1+((A_2+A_3)&(A_4+A_5))+A_6'; >> Fq = regexprep(Eq, '^([A-Z]+_)(.*)', '$1\(${strrep($2,$1,'''')}\)') Fq = A_(1+((2...

6 years ago | 0

| accepted

Answered
How to Set Specific Arg in Function
"I've tried seraching for how to change/edit/give a specific argument but I can't find it. I've tried the following options but ...

6 years ago | 1

| accepted

Answered
How can i extract parameters from a vector at specific values
Use ismember: >> A = 1:10 A = 1 2 3 4 5 6 7 8 9 10 >> B = 11:20 B = 11 12 13 14 1...

6 years ago | 0

| accepted

Answered
Extracting data from strings with varying delimiters and column widths
You can insert delimiters between those numbers, e.g. using regexprep: str = regexprep(str,' *(\d+?) *(\d{1,4}\.\d+)','$1,$2,')...

6 years ago | 1

| accepted

Answered
Simplest way to save a vector to a variable with commas and braces
You can create a character vector: >> strrep(mat2str(a),' ',',') ans = [1,2,3,4,5] which you can save however you want. But t...

6 years ago | 0

| accepted

Answered
Sort certain matrix cells in a vector
Linear indexing: >> G = Start_Matrix([15;16;18;12;13;14]) G = 78.808 83.353 112.37 188.5 ...

6 years ago | 0

Answered
How do I convert strings stored in a cell array to numbers?
Here is a faster solution (which also does not rely of the evil eval hidden inside of str2num): >> C = {'Name','2/8','3/7','7/8...

6 years ago | 1

Answered
Trying to assign into multiple variables using a for loop
Use a cell array: N = s(1,1); C = cell(1,N); for k = 1:N C{k} = news(c,'Symbol',symbol(k),'Category',"Analyst Ratings");...

6 years ago | 1

Answered
combine 30.mat file having 1*15 matrix (Each .mat file having 1 row and 15 columns) to one .mat file
The best approach is to follow the examples in the MATLAB documentation: https://www.mathworks.com/help/matlab/import_export/pr...

6 years ago | 1

| accepted

Answered
Comparing cell with criteria
out1 = cellfun(@(l,r) setdiff(1:9,[l,r]), Spfcfef(:,1), Spfcfef(:,2), 'Uni',0); out2 = cellfun(@(l,r) setdiff(l,r), Spfcf...

6 years ago | 0

| accepted

Answered
Splitting a vector into separate vectors using thresholds
Simpler and more robust: >> x = [9,15,9,23,15,9,15,7,99,0,12] x = 9 15 9 23 15 9 15 7 99 ...

6 years ago | 0

| accepted

Answered
How can I import multiple .CSV files in MATLAB with no sequential filename?
P = 'relative/absolute path to the folder where the files are saved'; S = dir(fullfile(P,'*.csv')); for k = 1:numel(S) F...

6 years ago | 4

| accepted

Answered
Find function in matlab
find returns the indices of non-zero elements of an array. You provided find with a logical array with these values: >> a>10 a...

6 years ago | 2

| accepted

Answered
What is the best way to create a vector with a special sequence of subvectors
Store the vectors in one matrix, then you just need to use nchoosek to generate the required indices: >> M = randi(9,5,3) % eac...

6 years ago | 0

| accepted

Answered
Converting numbers into logicals
>> A = {[3;5;6;8],[2,3,5]}; % fake data >> B = cell2mat(cellfun(@(v)ismember(1:9,v),A(:),'UniformOutput',false)) B = 0 0 ...

6 years ago | 0

| accepted

Answered
Indexing a matrix with an array
Use a cell array, e.g.: C = {2,3}; % use NUM2CELL(I) if required. A(C{:}) Tested: >> A = rand(4,4) A = 0.340974 0.252...

6 years ago | 0

| accepted

Answered
Expanding the existing Matrix
Use repelem or kron, e.g. where V is your input vector: Z = repelem(V,24) or Z = kron(V,ones(24,1)) % adjust to suit V's orie...

6 years ago | 0

| accepted

Answered
How to concatenate a 3D cell array along the 3rd dimension?
In one line using num2cell, cellfun, and vertcat: >> C1 = cell(2,2,3); % preallocate cell array. >> C1(:) = cellfun(@(~)rand(1...

6 years ago | 0

| accepted

Answered
How to find the element of a number if that number were to be placed in an ordered list?
The robust solution: >> ida = find(list<number,1,'last') ida = 3 >> idb = find(list>number,1,'first') idb = 4

6 years ago | 2

| accepted

Answered
fprintf can't make new line
Try opening the file in text mode, not binary mode: A = 5; tcl = regexp(fileread('old_file.tcl'), '[\n\r]+', 'split')'; tcl{3...

6 years ago | 1

| accepted

Answered
Same number of Rows and Cols of a matrix (N*N)
This will return false for non-square matrices, and also if ndims>2: isequal(0,diff(size(M))) It is easy to use with assert: ...

6 years ago | 0

Answered
complex plots bug?
"Am I doing something wrong or is this a bug in Matlab plotting?" There is no bug in the plotting. Exactly as documented, when...

6 years ago | 0

| accepted

Answered
How to store " first_element " values?
No loop needed, here using accumarray: >> A = [1,1,1,1,2,3,4,4,4;1,2,3,4,5,5,5,5,5] A = 1 1 1 1 2 3 4 4 4 ...

6 years ago | 2

Answered
Converting a matrix of strings to a txt file
the format string need to have 3 conversion operators (or as many as you want on each line). the matrix needs to be tranposed. ...

6 years ago | 1

| accepted

Answered
How to find duplicated values and calculate the mean of them?
Here is one solution: >> M = dlmread('all_velocities.txt'); >> [~,~,X] = unique(M(:,1:2),'rows'); >> F = @(x) mean(M(x,:),1)...

6 years ago | 0

Answered
Extracting specific values from a Matrix
Use sub2ind: >> V = randi(1024,1,1280); % fake vector of row indices. >> M = rand(1024,1280); % fake matrix of data. >> S ...

6 years ago | 0

| accepted

Answered
Are these the same: set(0, ... and set(groot, ...
"Are these the same: set(0, ... and set(groot, ..." No, they are not the same. Not even close to being the same. Zero is a num...

6 years ago | 1

| accepted

Answered
Dealing with flags that are really comments
6. Give feedback to TMW that suitably rated users need the ability to change thread object types (without changing their other p...

6 years ago | 1

| accepted

Answered
Counting specific element in one column corresponding to unique elements in an another column
>> a = [1;1;1;1;1;2;2;2;2;2;3;3;4;4;4;5;5;5;5;5;5]; >> b = [1;1;-1;1;-1;-1;-1;-1;1;1;-1;1;1;-1;-1;1;1;-1;-1;1;1]; >> u = uniqu...

6 years ago | 0

Load more