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

Answered
Extracting arrays from a structure - different number of array elements
"I'm guessing that there is a NaN in one of them." A NaN is scalar, so would not cause this. However an empty array could cause...

3 years ago | 0

| accepted

Answered
Processing data from multiple files
"what did i do wrong?" You tried to assign an array into a scalar location. Some of the other indexing will not work either, fo...

3 years ago | 1

| accepted

Answered
how can i use struct to "for" when i use predictFcn
"i have 15 number of sturct" And that is a problem which is best solved by putting them into one array (which they clearly shou...

3 years ago | 1

Answered
Making a datetime vector with a leap year
https://www.mathworks.com/help/matlab/matlab_prog/generate-sequence-of-dates-and-time.html D = datetime(2021,1,1); V = D:hours...

3 years ago | 0

Answered
Adding Exponent e.g. 10^_10 to Y Axis (normal code for this doesn't work.)
https://www.mathworks.com/help/matlab/creating_plots/change-tick-marks-and-tick-labels-of-graph-1.html M = 1e10*rand(7,5); plo...

3 years ago | 0

| accepted

Answered
find rows in a matrix where all the elements (of those rows) are not NaN
a = [NaN,NaN;NaN,NaN;NaN,NaN;7972,8160;NaN,NaN;NaN,NaN;8083,8343;NaN,NaN;NaN,NaN] b = rmmissing(a)

3 years ago | 0

Answered
How to save Char from Structure into Array MATLAB
S = load('Dataset.mat'); D = S.Dataset T = string({D.ClassName})

3 years ago | 1

Answered
why fread showing too many output arguments?
"So, does that mean 5-values represents 5-different parameters?" Yes, if that is what your file contains and the FREAD command ...

3 years ago | 0

| accepted

Answered
get folder names in a directory
Do NOT use CD just to access data files: absolute/relative filenames are more efficient and more robust. Rather than getting th...

3 years ago | 0

Answered
error in loading data from a sheet in .xlsx format
" I do have the sheet but matlab is still give me error." No, as the error message correctly states, there is NO sheet in that ...

3 years ago | 0

| accepted

Load more