Answered
Regular Expressions using regexp
Matching only integer numbers after 'UZK' or 'T_' (it is unclear in your question if the underscore is permitted or not, but the...

7 years ago | 1

| accepted

Answered
How to read elements from a computed matrix without define a new variable?
MATLAB does not allow indexing into the results of operations. You can either use a temporary variable (which is probably the mo...

7 years ago | 0

| accepted

Answered
Matrix Maipulation and adding from variables in the workspace
Load the file into a variable (which is a structure) and access its fieldnames: S = load(...)

7 years ago | 0

Answered
ERROR-The statement cannot be reached
Those warnings are very simple to understand by aligning the code and looking at the values. MATLAB warns you that lines 14 and...

7 years ago | 2

| accepted

Answered
Using semicolon for input argument when working with a matrix function
" I was thinking concatination, concatinating the same matrix 4 times but multiplying it by 1,2,3, then 4 as requested." It wou...

7 years ago | 2

Answered
Comma separated value to vector
>> S = '11,333,4445,2,78,2399'; >> V = sscanf(S,'%f,',[1,Inf]) V = 11 333 4445 2 ...

7 years ago | 0

| accepted

Answered
Replacing individual Values in Data column based on a condition
idx = myData.fluid_p_rel<0.9 | myData.fluid_p_rel>1.2; myData.fluid_p_rel(idx) = 1

7 years ago | 0

| accepted

Answered
How to convert column datetime to datenum?
It is not clear from your example what class data has: a table or a non-scalar structure or .. ? In any case, datetime objects ...

7 years ago | 1

| accepted

Answered
Error when calling a function : "Dimensions of arrays being concatenated are not consistent."
The full error message is this: Error using vertcat Dimensions of matrices being concatenated are not consistent. Error in fu...

7 years ago | 2

| accepted

Answered
Counting zeros in array
Simpler: >> V = [1,-2,-1,-1,-1,0,0,-1,0,0,0,3,0,0,4,0,0,0,0,0]; >> X = find([V(1:end-1),1]); >> Z = [diff([1,X+1])-1;V(X)].' ...

7 years ago | 3

Answered
Converting binary like table but using decimal values
You can use comma-separated lists on the output of ndgrid: https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-li...

7 years ago | 0

| accepted

Answered
How do i compare cell array values and replace with string of code letters?
Method one: >> C = {'UUU','CUU','UUC','UUG'}; >> F = {'UUU','UUC'}; >> L = {'UUA','UUG','CUU','CUC','CUA','CUG'}; >> Xf = is...

7 years ago | 0

| accepted

Answered
How to get nearest values in matrix and save indexes of these values?
>> X = [5,10,15]; >> Y = 0:7/5:30; >> [~,Z] = min(abs(X-Y(:))) % the indices of the closest values: Z = 5 8 12 ...

7 years ago | 2

| accepted

Answered
Operation on structure fields with common part of the field name
S.DUT_2 = 2; S.REF_2 = 3; S.DUT_4 = 4; S.REF_4 = 5; C = fieldnames(S); U = unique(regexp(C,'\d+$','once','match')) F = @(n...

7 years ago | 0

| accepted

Answered
how to change multiple items in a text file?
EDIT: much faster: rpl = '2.5'; % the new value (you can generate this using NUM2STR). str = fileread('bp.txt'); str = strtri...

7 years ago | 0

| accepted

Answered
Extracting numbers from a G-code file
Simple use of one regular expression is all that you need to identify those X, Y, and E values: str = fileread('test.txt'); rg...

7 years ago | 6

Answered
Adjusting the dimensions of input argument
A = A(:).';

7 years ago | 1

| accepted

Answered
How to convert string to number?
"...how do I convert it back to a number?" Convert to numeric: num = str2double(id1) "Now i want to check if the value is a n...

7 years ago | 0

Answered
How can I make a random RGB array of either White Cells or Green Cells (or any two colours)?
This generates MATLAB standard 0-1 values (multiply by 255 and use uint8 if required): >> R = 5; >> C = 7; >> X = rand(R,C)<0...

7 years ago | 0

| accepted

Answered
Access to array of structs (no for loops)
"Is there a way to access all end values of datarow with one command (no for loops or temporary variables)?" Nope. "Anyone som...

7 years ago | 0

| accepted

Answered
Matlab adds a minor number to integer - why?
"i noticed a very strange phenomanon:" Nope, not strange at all. "what is the "3" in the end..." Accumulated floating point e...

7 years ago | 1

Answered
The usage of [~,I]=min(abs(A+B)) on a specific example
I don't really see how min can help you. Basic logical indexing would be simpler, e.g.: >> nnz(u<umin | u>umax) ans = 4 Note...

7 years ago | 0

| accepted

Answered
Variable changes to previously calculated value each iteration.
This is very easy with a preallocated vector (giving exactly the values as you stated here): X = 100:440; N = numel(X); Z = n...

7 years ago | 1

| accepted

Answered
Concatenation of variables inside a struct
Method one: size and repelem: >> cnt = arrayfun(@(s)size(s.latlon,1),str); >> out = repelem(cat(1,str.val),cnt) out = 200...

7 years ago | 0

| accepted

Answered
How can I create a cell array whose elements reflect a length based on a given input vector?
In one line: >> V = [3,2,4]; >> S = 'b'; >> C = mat2cell(repmat(S,1,sum(V)),1,V); >> C{:} ans = bbb ans = bb ans = bbbb

7 years ago | 0

| accepted

Answered
Multi-conditional statements for array lookup (similar to multi-conditional vlookup from Excel)
You could use tables and innerjoin: >> tA = cell2table(A,'variableNames',{'class','thickness'}) tA = class thickness ...

7 years ago | 1

| accepted

Answered
Creating folders outside of the current folder
Of course, just define the parentFolder, or use a relative/absolute path: https://www.mathworks.com/help/matlab/ref/mkdir.html#...

7 years ago | 0

| accepted

Answered
Adding neighboring numbers in a cell to another cell
CA = {[5,-10,2],[6,6,-10],[0,9,-10,8,-10,3]}; CB = {[4,17,2],[6,6,10],[9,3,4,9,7,6]}; for k = 1:numel(CA) idx = 1+find(-1...

7 years ago | 0

| accepted

Answered
How to append structure fields with same name and different length
You did not explain how these (identically named) files are saved (i.e. what the folder structure is like), so I simply put your...

7 years ago | 0

| accepted

Load more