Answered
Find string inside a cell array
Skip the loop and use ismember: S = dir('D:\ABIDEdataset\Outputs\dparsf\nofilt_noglobal\rois_aal\All_Groups'); C = extractfie...

5 years ago | 0

| accepted

Answered
MATLAB input function error; Output arguments.
You have created/added a function with name input, which shadows the inbuilt input function. Use which to find the location of ...

5 years ago | 2

| accepted

Answered
Use an input for a function
Use the 's' option to return the input unevaluated (i.e. as a character vector): https://www.mathworks.com/help/matlab/ref/inpu...

5 years ago | 0

| accepted

Answered
is there a cmd which can justify a script at once?
In the MATLAB editor: select the text you want to align (e.g. ctrl+a) press ctrl+i

5 years ago | 0

| accepted

Answered
Import several tables from one txt file in Matlab
str = fileread('temp.txt'); tkn = regexp(str,'^#TableID[^\n]*\s*([^\n]+)([^#]*)','lineanchors','tokens'); tkn = vertcat(tkn{:}...

5 years ago | 1

| accepted

Answered
Removing empty cells from cell array
Most likely converting the nested cell array to numeric arrays is going to make processing your data easier: S = load('G.mat');...

5 years ago | 0

| accepted

Answered
if statement with changing values
if numel(intersect(ID1,ID2))

5 years ago | 0

| accepted

Answered
Indexing for 4-D Arrays
You could use sub2ind: %% Build array dim = 40; volume = rand(dim,dim,dim,3); % simpler! %% Request data from 4d array ve...

5 years ago | 0

| accepted

Answered
My loop can't (sometimes...) evaluate its variable
"did I use something wrong ? " You are testing for exact equality of binary floating point numbers, which is unlikely to be rel...

5 years ago | 0

| accepted

Answered
regexp: extra cell layer in the output
"Could you please suggest me a way to force regexp to output a pure 1x4 cell array of tokens?" The simple answer to your questi...

5 years ago | 2

Answered
Plot datetime data from a cell array?
A cell array containing lots of scalar arrays indicates that your data is arranged sub-optimally. You would be much better off u...

5 years ago | 0

| accepted

Answered
Inserting new element after each element of an array
The MATLAB approach: arr = [2,4,6]; mat = repelem(de2bi(arr,'left-msb'),1,2)

5 years ago | 1

| accepted

Answered
How can i generalize "if statement"
Assuming that x is a four-element numeric vector or logical vector, something like this should work: if any(x) edges = edg...

5 years ago | 1

| accepted

Answered
How to shift entries in a vector by the value of the number in that entry?
T = [0, 0, 4, 0, 7, 0, 0, 5, 0, 9] N = numel(T); X = 1+mod(T+(0:N-1),N); for k = 1:N T([k,X(k)]) = [0,T(k)]; end disp(...

5 years ago | 0

| accepted

Answered
Plot multiple lines from multiple tables
By numbering your variables like that you have made the task a lot harder and more complex. The simpler and much more efficient...

5 years ago | 0

| accepted

Answered
Appending strings to array
"l = zeros(1,length(str)); % defining my empty list " That is not an "empty list": MATLAB does not have a "list" type. It is ...

5 years ago | 1

Answered
How can I remove characters in cvs file?
Using string manipulation: str = fileread('prueba1.csv'); str = strrep(strrep(str,'"',''),';',' '); mat = sscanf(str,'%f',[3,...

5 years ago | 0

| accepted

Answered
add Int8 and int16
add_int(int8(127),int16(129)) function out = add_int(in1,in2) out = int16(in1) + int16(in2); end

5 years ago | 1

Answered
Problems using "datetime" cont.
You should probably specify the input format to match the provided string: S = "12/24/2008 9:59:47 AM.786743640"; D = datetime...

5 years ago | 0

| accepted

Answered
Mean of matrix subarrays without using a loop.
A = [1 0 3 5 0 7; 0 2 6 0 8 0; 3 5 0 0 2 0] B = reshape(A.',3,[]); B(B==0) = NaN; C = reshape(mean(B,1,'omitnan'),[],size(A,1...

5 years ago | 1

| accepted

Answered
Extracting a matrix element which is within a cell containing cells.
Putting scalar numeric data into nested cell arrays is pointlessly complex and inefficient. Get rid of the cell arrays: S = loa...

5 years ago | 0

| accepted

Answered
get specific range of data from vector, indicated by other vector
X = [13500, 14628, 18500, 20788, 24567]; N = numel(X); C = cell(1,N); for k = 1:N Y = (X(k)-3000):X(k); C{k} = data...

5 years ago | 0

| accepted

Answered
how to create a matrix in matlab?
M = dec2bin(0:7)-'0'

5 years ago | 1

Answered
Find a specific char in a cell and turn it into NaN
F = 'UmgebungsmessungDez.csv'; S = detectImportOptions(F, 'Delimiter',';', 'VariableNamingRule','preserve'); X = false(1,numel...

5 years ago | 0

Answered
Move value at index i from one array to another array but at index 3 * i
Robust and reasonably efficient: n = 3; % scale a = 1:3 a(2:n,:) = 0; a = a(1:1-n+end)

5 years ago | 0

Answered
How can I call a matrix entry inside a struct (using sprintf)?
"Since the code is meant to be as short and simple as possible.... Is there any way to utilize the sprintf function or any other...

5 years ago | 0

| accepted

Answered
How to import a text file, including a time column, commas as points, and tabs as delimiters, into workspace as a matrix
F = 'test data.txt'; T = readtable(F, 'Delimiter','\t', 'DecimalSeparator',',', 'VariableNamingRule','preserve')

5 years ago | 1

| accepted

Answered
naming saved files in a for loop
What you wrote: save('savename_masq', 'masqpatient'); What you should write: save(savename_masq, 'masqpatient')

5 years ago | 0

Answered
hex2dec broken in R2020a?
format long str = 'ad55cb92eef08aea93f27c40457f8835'; val = hex2dec(str(01:16))*pow2(64) + hex2dec(str(17:32))

5 years ago | 0

Answered
Numbers as multiply of pi?
atan(sqrt(sym(3))/1)

5 years ago | 1

| accepted

Load more