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

Answered
scalar matrix operations / vector arithemtics
"but as you can see the result is wrong.." No, I do not see that. I see the default format which has four digits after the deci...

3 years ago | 1

| accepted

Answered
Extracting values from a char variable
str = fileread('text.txt') In three separate REGEXP calls (combining may be possible, but only with significant effort and comp...

3 years ago | 0

| accepted

Answered
Removing elements of a cell array that start with a specific letter
"What is the easiest way to do this?" Where C is your cell array: X = startsWith(C,'R'); C(X) = []

3 years ago | 0

| accepted

Answered
Need help with regexpi expression for multiple variants of the same phrase
https://www.mathworks.com/help/matlab/matlab_prog/regular-expressions.html#f0-42884 You will probably find the 'ONCE' option al...

3 years ago | 0

Answered
How to convert this string to a datetime?
D = ['2003/06/24' '2003/07/10' '2003/07/10' '2003/07/10' '2003/07/18' '2003/07/26' '2003/08/03' ...

3 years ago | 0

| accepted

Answered
How to speed up operation in two 'for' loops?
"How can I improve?" In general importing/exporting data is slow. So rather than calling READMATRIX 58732*numel(S) times in a l...

3 years ago | 0

| accepted

Answered
How to add zeros diagonally in a matrix?
A = [2,2,1,3,2;1,3,3,1,2;3,1,4,4,1;2,2,1,3,3] S = size(A)+[1,0]; B = zeros(S); B(~eye(S)) = A

3 years ago | 0

| accepted

Answered
How to use 'UniformOutput' and 'ErrorHandler' together in 'arrayfun' function?
"Can anyone please check if my code is correct..." It is not: you have called ARRAYFUN() with two output arguments, therefore b...

3 years ago | 0

| accepted

Answered
Is it possible to use vertcat with dot notation?
"The error is being caused by the fact that filename is not a struct." FILENAME is a struct (as returned by DIR). Curly brace i...

3 years ago | 1

| accepted

Answered
Copied struct ends up in "ans" instead of new struct (within function)
"The eval function basically excutes: number of ones varies depending on n ... Dependent.value{n} = reshape(Dependent.value{n},...

3 years ago | 0

Answered
Getting Data from Cell: Dynamic Structure needed?
"Does this not need a dynamic structure?" I don't know what a "dynamic structure" is, but it looks like some very basic indexin...

3 years ago | 1

| accepted

Answered
How can I merge the matrices that produce different dimensions in the loop
Simply put them all into one cell array and then concatenate after the loop: N = the number of loop iterations C = cell(1,N); ...

3 years ago | 0

Answered
Merge nx3 double matrices present within a 3x1 cell
Simpler code and much more efficient use of MATLAB: a=randi(100,157,2); b=randi(200,189,2); c=randi(300,183,2); tmp = {a,b,c...

3 years ago | 0

Answered
How to copy data of one or more variables from one Mat file to another Math file?
S = load('2sn20.mat', 'one1'); save('2sn20Vectorized.mat', '-struct','S', '-append')

3 years ago | 0

Answered
How to transform a table to a nested structure comparable to a pivot table in excel?
"I want to calculate the mean of value 1 for all data where test='A', condition='C', participant='X' and date='d1'" The MATLAB ...

3 years ago | 0

| accepted

Answered
How to locate the index of a certain date for a date-time array?
You are working with datetimes, so do not compare text! dt = datetime(2017,1,1,(0:1:123).',0,0, 'Format','u MM dd eee HHmmss') ...

3 years ago | 0

| accepted

Answered
deal array contents into cell arrays
C = cell(3,2) S = ["cat","hat";"hello","world";"A","B"] [C{:}] = deal(S{:}) https://www.mathworks.com/help/matlab/matlab_prog...

3 years ago | 0

| accepted

Answered
Datetime cannot parse certain literal months
According to american logic, the british three-letter appreviation of September is "sept": datetime('05 Nov 2021','InputFormat'...

3 years ago | 2

| accepted

Answered
How to concatenate this matrix?
A = [1,4,7,10,13,16,19,22,25;2,5,8,11,14,17,20,23,26;3,6,9,12,15,18,21,24,27] B = reshape(permute(reshape(A,3,3,[]),[1,3,2]),[]...

3 years ago | 1

| accepted

Answered
How to standardize an array so that the maximum value is 1 and minimum is -1 keeping the zero value as zero?
In just one simple step, assuming that the min<0 and max>0: A = [-1,-2,-3,-4,0,1,2]; B = interp1([min(A),0,max(A)],[-1,0,1],A)...

3 years ago | 1

Answered
Passing arguments through a function
As I understand it, your goal is to alllow for an arbitrary number of named input arguments, without needing these to be explici...

3 years ago | 0

Answered
Extracting the last string of a path
P = '/Users/Loup/Documents/MATLAB/HMM_Project_forS/Scripts/test/Rec 06-All-Data'; [~,D] = fileparts(P) Strictly speaking, if t...

3 years ago | 0

Answered
How to extend a curve with a desirable shape?
This would be much easier if you had uploaded some data. Instead I will have to invent some fake data. Adjust the values to suit...

3 years ago | 0

| accepted

Answered
can any one tell me why that function can not run??
x(n) = .. ^^^ because of this indexing Fixed: n=-5:5; x=y(n); x1=y(n-1); x2=y(n+1); subplot(3,1,1) stem(n,x); grid o...

3 years ago | 0

| accepted

Load more