Answered
compensate vector into same length
The simplest approach is to download the function PADCAT() here: https://www.mathworks.com/matlabcentral/fileexchange/22909-pad...

3 years ago | 0

| accepted

Answered
How to solve 1.0000 not equal to 1 in MATLAB?
"How to solve 1.0000 not equal to 1 in MATLAB?" There is nothing to "solve", because 1.0000 is not equal to 1 (note the trailin...

3 years ago | 2

Answered
for loop multiple string replace
MATLAB is designed to work neatly and efficiently with arrays. Rather than doing things one-at-a-time like that, you should be u...

3 years ago | 0

| accepted

Answered
I couldn't understand the problem in this code.
Somehow you have managed to include NO BREAK SPACEs in the your code: https://www.unicodepedia.com/unicode/latin-1-supplement/a...

3 years ago | 0

Answered
How to change only one element in cell matrix and keep the rest elements constant?
"This is a complete 4-D matrix and I need to work with this matrix." Note that it is a 4D cell array, not a numeric array. Usi...

3 years ago | 1

Answered
Loading Files using a Loop with a predictable name pattern
P = 'absolute or relative path to where the files are saved'; N = 10; C = cell(1,N); for k = 1:N F = sprintf('IGP_Small_...

3 years ago | 1

| accepted

Answered
Creating a new cell array which is a subset of another cell array
D = Output; % preallocate for k = 1:numel(D) D{k} = Output{k}(C,:); end

3 years ago | 0

| accepted

Answered
Why my error handling function not working for multiple outputs?
"Why my error handling function not working for multiple outputs?" The problem has nothing to do with the two outputs, the prob...

3 years ago | 1

| accepted

Answered
Accessing field names in struct
test = struct(... 'a',false,... 'b',false,... 'c',false,... 'd',false,... 'e',false,... 'f',false...

3 years ago | 1

Answered
Converting an old Matlab code from 2011 to work with newest version
"I have very limited Matlab skills ..." Don't learn from that badly-written code. Use function handles! "This eval([method... ...

3 years ago | 1

| accepted

Answered
how to subtract the datetimes
ac = {'12/09/2022 04:28:01 PM'}; bc = {'12/09/2022 04:28:26 PM'}; at = datetime(ac, 'InputFormat','M/d/y h:m:s a') bt = datet...

3 years ago | 0

| accepted

Answered
savefigures with filenames from a cell array
You are already calling SPRINTF() to generate the filename, so just provide it with the text input too: vars = {'A','B','C','D'...

3 years ago | 1

| accepted

Answered
Hi,how do I merge .txt file date and time column?
This is easy and more efficient using the READTABLE() options: fnm = 'IMM2211.txt'; obj = detectImportOptions(fnm, 'NumVariabl...

3 years ago | 2

Answered
Splitting integers and floating values from a string in MATLAB
Here an approach which returns a table, which might be more useful for accessing your data: T = readtable('ex.txt', 'NumHeaderL...

3 years ago | 1

| accepted

Answered
How do I compare a cell array containing string arrays against a string array without using loops?
S = load('answersData.mat'); A = S.tableOfTextByTime.("tweetUniqueMentions") B = S.tableOfUsers{:,1} tic T = vertcat(A{:}); ...

3 years ago | 1

| accepted

Answered
How can i create cell array from matrix?
noP = 2; x_set = [50,44,0.03,0.13]; C = repmat({x_set},noP,1)

3 years ago | 0

| accepted

Answered
Dot indexing is not supported for variables of this type
IMAGES is a cell array, so you need to use curly braces to access its content: images{ii}.Neighborhood % ^ ^ TITLES is a...

3 years ago | 1

Answered
textscan different number of floating digits
"...but I need to order them according to the last part which is 30.0m 31.65m 33.5m" So why not just sort the filenames? That ...

3 years ago | 0

| accepted

Answered
Add string files to a cell array within a loop
Simpler using COMPOSE(): user = 'user'; runs = [1,2,3]; subj = 1; fmt = 'C:\\Users\\%s\\Documents\\BIDS__dataset\\sub-%02d\\...

3 years ago | 0

| accepted

Answered
How to extract date, month, year, and time from a table data?
The MATLAB approach is to use YMD() and TIMEOFDAY() and HOURS(): S = ["2016-01-01 00:30:00"; "2016-01-01 01:00:00"; "2016-01-01...

3 years ago | 0

Answered
how to solve not enough input argument error?
Your code is not written to handle cases when s is non-scalar. Your code assumes that s is scalar, but does not check this an an...

3 years ago | 0

| accepted

Answered
I want to add a filename to a struct variable.
A better (simpler, neater, more efficient) use of MATLAB is to just collect the logical values inside the loop, and then use bas...

3 years ago | 2

| accepted

Answered
Finding index in a set
Simple and efficient: x1 = [0,0,1,0]; x2 = [0,0,0,0]; ix = find(~x1); iy = randi(nnz(ix),1); x2(ix(iy)) = 1

3 years ago | 1

| accepted

Answered
Calculate values inside a loop and store them in variables.
Assuming that SUM() returns a scalar: V = [1:10,15:5:50]; C = V; % preallocate for k = 1:numel(V) % loop over indices, not yo...

3 years ago | 0

| accepted

Answered
pre-allocation in loop
"However I think I have already done it at least with MATRICI_SIMULATE_nonan." There is nothing like preallocation in your code...

3 years ago | 1

Answered
Problem with defining a path to a MATLAB function
P = '~/Desktop/Data/pat01_t1/'; % do NOT use PATH as a variable name. Brain = load_untouch_nii(fullfile(P,'Brain.nii')); Most ...

3 years ago | 1

| accepted

Answered
How to write a .tsv file?
C = {'hello',1;'world',3.14159} writecell(C,'test.tsv', 'filetype','text', 'delimiter','\t') Checking: type test.tsv

3 years ago | 0

| accepted

Answered
Creating variables and assigning values from table data
"Is there any way I can create these variables directly from the table data?" Easy, just convert the data to a structure and SA...

3 years ago | 0

Answered
DIR Index exceeds number of array elements
Problem: you have created a variable named DIR, here on this line: dir = pwd; Solution: get rid of that line of code and clear...

3 years ago | 0

| accepted

Answered
How do I rectify the error corresponding to the Dimensions of arrays being concatenated no being consistent
Making a wild guess about the wanted output array size: ECG_l = ECG([1,1:end,end],:);

3 years ago | 0

| accepted

Load more