Answered
Getting all values in the same field for different entries within a structure
"Is it possible to get all the different math grades in an array without a for-loop?" Of course. The simple and efficient MATL...

3 years ago | 0

Answered
How to change HH:mm:ss:SSS to HH:mm:ss.SSS for a column?
time = {'01:18:34:754'; '13:04:19:999'}; data = rand(2,1); T = table(time,data) tmp = regexprep(T.time,':(?=\d{3})','.'); T....

3 years ago | 0

Answered
error when using '>' , Operator '>' is not supported for operands of type 'table'.
if significant{i,j} > 2 % ^ ^ https://www.mathworks.com/help/matlab/matlab_prog/access-data-in-a-table.html

3 years ago | 0

Answered
Copy variables into excel smoothly
"So I wonder how I can work around this?" Don't copy-paste data into Excel. The simple, easy, robust approach is to use WRITEMA...

3 years ago | 1

| accepted

Answered
Fill a matrix with another buy keep the original size
A = zeros(5,5); B = rand(3,5); A(1:size(B,1),:) = B https://www.mathworks.com/help/matlab/getting-started-with-matlab.html

3 years ago | 1

| accepted

Answered
Adding to existing date value
"Using caldays does not update the month" Yes, it does: dt = datetime(2023,3,27, 'Format','u-MM-dd') dt = dt+caldays(5) Appa...

3 years ago | 0

Answered
Why is NaN returned when I have all necessary input data?
"Does anyone see my mistake?" Your data has a range of approx 0.166: how many peaks do you expect to get with minimum peak prom...

3 years ago | 0

Answered
How do I change the name of a variable (actually value of a character array) inside a loop?
"I do not see any oher solution then to edit the name while in the loop." What you are asking is just to change some text. This...

3 years ago | 0

| accepted

Answered
regexp string to numeric array
Assuming that every string contains exactly the same number of numeric data: str = {'bob22alice666buster2', 'donald42lisa00budd...

3 years ago | 0

Answered
finding a numeric pattern in a vector
Your basic concept is okay. You need to select an appropriate character match and quantifier. Note that the asterisk is actually...

3 years ago | 0

| accepted

Answered
Merging Date and time
Rather than fiddling after importing, the best approach is to import the file correctly using READTABLE options, e.g.: fnm = 'L...

3 years ago | 2

| accepted

Answered
Efficient way to convert m by n array into a single column table with each row containing n by 1 array?
A = [1 3 5; 2 6 7; 5 8 9; 3 2 1]; T = cell2table(num2cell(A.',1).')

3 years ago | 0

| accepted

Answered
Rearrange cell array of strings based on occurrence in another cell array of string
Assuming that every text in B contains exactly one text from A, and that every text in A occurs in B: A = {'test1', 'test2', 't...

3 years ago | 0

| accepted

Answered
I don't know how to use if function with or operator
The simple MATLAB approach: if any(data(i,1)==[0,0.0625,0.125,0.25,0.5,1,2,4,8,16,32]) or even simpler: if any(data(i,1)==[0,...

3 years ago | 2

Answered
readmatrix error: "filename" must be a string scalar or character vector.
Get rid of DIR from inside the loop. P = 'C:\Users\aasyuda\Documents\CV-EIS\aptamer-histamin\14April2023\14April2023\0p0001nM';...

3 years ago | 0

Answered
Writing txt files accurately with a restriction on the number of columns.
V = randi(123,1,23) T = sprintf('%g,',V); U = regexprep(T,'(.{1,13}),','$1\n'); % e.g. max 13 columns fprintf('%s',U) And if...

3 years ago | 2

Answered
How do I put spaces before a line in a txt file using strcat and fprintf?
STRCAT removes whitespace characters. The easy and robust approach is separate FPRINTF calls: fprintf(fid_wrt,' \n') fprintf...

3 years ago | 0

| accepted

Answered
Generate comma separated list in single line of code?
A one-line approach that has been possible since R2019b: struct('x',{'A','B','C','D'}).x https://www.mathworks.com/help/releas...

3 years ago | 0

Answered
compare variable with different data types
Here is a neat approach that also allows case-insensitivity: x = 'Yes'; % x can be char, string, logical, or numerical if strc...

3 years ago | 0

| accepted

Answered
Concatenate all arrays from a field in a structure
Where S is your structure: A = vertcat(S.A) B = vertcat(S.B) etc. https://www.mathworks.com/matlabcentral/answers/1656435-tu...

3 years ago | 1

| accepted

Answered
Access and extract table array using for loop
"I need to extract (or access) the data using "for loop". For example, from "ECG", we can extract the data from 0 sec, 10 sec, 2...

3 years ago | 0

Answered
Merging empty vector with double
"if B is empty, I want it to be shown as 9 zeros" A = [1;2;3;4;5;6;7;8;9]; B = []; C = []; C(1:numel(A),1) = A; C(1:numel(B...

3 years ago | 0

| accepted

Answered
Execute script on multiple Files
With many assumptions, e.g. that the required folders are all subfolders of one parent folder. You should also pay attention to...

3 years ago | 0

| accepted

Answered
How do I extract data from a structure and put them all in one single array?
https://www.mathworks.com/matlabcentral/answers/1656435-tutorial-comma-separated-lists-and-how-to-use-them S = vertcat(dataTT.D...

3 years ago | 0

| accepted

Answered
How to loop through a specific file in various subfolders inside a main folder?
The simple robust MATLAB approach is to get DIR to do most of the heavy lifting. It is very easy for DIR to loop over subfolders...

3 years ago | 0

Answered
Array rows differences and array filling in a loop
No loops required, the simple MATLAB approach is to use NCHOOSEK: A = [1,3;2,5;4,6;7,10;100,150;230,270] P = nchoosek(1:size(A...

3 years ago | 3

| accepted

Answered
too many output arguments when calling axis in cellfun
"It has no output argument." Yes, it does. Every expression inside the curly-braces is evaluated and its output is requested. W...

3 years ago | 0

| accepted

Answered
Get error about table creating
CAUSE: the bug is caused on this line, where you create a variable named TABLE: table = table(..) After you do that, then TABL...

3 years ago | 0

| accepted

Answered
How to find the exact toolbox being used from the license name ?
See the table here: https://www.mathworks.com/matlabcentral/answers/377731-how-do-features-from-license-correspond-to-names-fro...

3 years ago | 0

| accepted

Answered
Precision of num2str function
If you want that much control over the text format then you should be using SPRINTF. But in lieu of that, you can specify the f...

3 years ago | 0

| accepted

Load more