Answered
Argument validation for cell arrays?
"that the argument must be a cell array of three-vectors." You can easily write your own argument validation function: https:/...

3 years ago | 1

| accepted

Answered
extract all rows of a matrix except 'r' (vector) rows
The most efficient approach: matrix = [54; 55; 56; 57; 58; 59; 60; 61; 62; 63; 64; 65]; r = [1; 2; 3; 4; 9]; matrix_out = mat...

3 years ago | 0

| accepted

Answered
Averaging a curve with itself
S = load('test.mat'); Xraw = S.cx; Yraw = S.c; [Xmin,Imin] = min(Xraw); [Xmax,Imax] = max(Xraw); I1 = Imin:Imax; I2 = [I...

3 years ago | 0

Answered
Operation with logical data. Which is better?
n = 5; a = [1,9,0,2,3]; b = a<n & a

3 years ago | 0

| accepted

Answered
Can I create cells inside cells in for loop?
Brute force naive approach: P = perms(1:9) C = {1:3,4:6,7:9}; B = true; for k = 1:numel(C) V = C{k}; [X,~] = find(...

3 years ago | 0

Answered
Writing functions f(x,y)
fh1 = @(x,y) 4*(x-1).^2 + 3*(y-2).^2 + 2*(x-2).^2.*(y-3).^2; fh2 = @(v) fh1(v(1),v(2)); % function with one input sol = fminse...

3 years ago | 2

Answered
I would like to merge two different column in one as datetime
% Fake data: A = ones(5,1) B = {'0:00';'0:05';'0:10';'0:15';'0:20'} % Convert to DURATION: M = str2double(split(B,':')); D ...

3 years ago | 0

Answered
How to solve error "access denied" when using mkdir?
Explanation: The basic problem is that you are calling MKDIR using command syntax (not function syntax), but are expecting to p...

3 years ago | 0

| accepted

Answered
Faster indexing from Matfiles with similar names
"What I meant when I said I had 5 matfiles called m1 to m5 is that m1 - m5 were matfile-type variables obtained by calling the m...

3 years ago | 0

| accepted

Answered
Common Elements in Two 2D Arrays
A = [1,2,3,4,5,6; 3,1,2,4,5,7] B = [1,1,3,5,6,7; 3,1,2,4,5,7] Method one: ALL and indexing: X = all(A==B,1); C = A(:,X) Met...

3 years ago | 1

Answered
In what situations do we need to use the `empty` method? What benefits does the `empty` method provide?
"In what situations do we need to use the `empty` method?" Whenever you want to create an empty array of a certain class. Certa...

3 years ago | 1

Answered
Reading file names from a certain directory into a cell array to compare it with a different cell array
"I know how to do the comparisson just not how to get the filesnames from the directory" Use DIR: https://www.mathworks.com/he...

3 years ago | 1

| accepted

Answered
How to identify blocks in a diagonal block matrix?
This is not very pretty, but it gets the job done. Note for simplicity it only handles square matrices and assumes square, non-o...

3 years ago | 1

| accepted

Answered
Table Multiplication error: Both tables must have the same variables
One simple solution is to use curly braces to access table content (not parentheses which return another table): SAI{:,1} .*SAI...

3 years ago | 1

| accepted

Answered
error while converting to string
"However, I want the value of m to remain 08." Numeric data classes do not store formatting information e.g. how many leading z...

3 years ago | 0

| accepted

Answered
Why is the If Statement Not Working?
This code if i 1 | 4 is exactly equivalent to writing if i 1 | 4 where the second line is calculated and the result imm...

3 years ago | 0

| accepted

Answered
How can I create an array(not a cell array) for every iteration of a for loop
Fake data: V = rand(1,99); W = [3,9;13,17;64,91]; % [start,end] Approach one: ARRAYFUN and CELLFUN: F = @(b,e) V(b:e); C = ...

3 years ago | 0

| accepted

Answered
Finding name of single frames when reading a Tiff stack file
This is what GIMP found hidden amongst the EXIF data: It looks like some tool has added some non-standard EXIF meta-data. Not...

3 years ago | 0

| accepted

Answered
How to convert hours, minutes, seconds to seconds?
The approach for MATLAB >=R2014b is to use the DURATION class, e.g.: C = {'14:54:25'; '14:54:25'; '14:54:25'; '14:54:26'; '14:5...

3 years ago | 1

Answered
error using the join function
"What went wrong?" You need to provide multiple key names as one input argument, not as two separate input arguments. This mean...

3 years ago | 0

Answered
Create a matrix of HEX number from a file of HEX number separated by a space
S = readmatrix('test.txt', 'OutputType','string')

3 years ago | 2

Answered
how add "$" and "' ' " in array string
format long G V = [0;-23;123.456;-0.78;9;1234567.89;-987654321;7;-54321] S = compose("$ %.2f",V(:)); S = regexprep(S,"(\d{1,3...

3 years ago | 1

Answered
How to make Matlab give different answers for different text inputs of different lengths
"What am I doing wrong?" You are using EQ (i.e. ==) for character arrays, which performs a character-by-character comparison (e...

3 years ago | 0

| accepted

Answered
How to calculate the length of a curve with known coordinates (x,y)?
The simplest approach is to download John D'Errico's excellent ARCLENGTH function: https://www.mathworks.com/matlabcentral/file...

3 years ago | 0

Answered
fplot glitch when plotting a square function
"Can anyone comment on what is causing this behavior?" The main cause is missing from your list: mathematics. It essentially co...

3 years ago | 3

| accepted

Answered
sorting alphabetically with sortrows: underscore handled differently than in windows
I had a requirement to sort some non-English text into alphabetic order (or even better, alphanumeric order). I first looked at ...

3 years ago | 1

Answered
table stats - summary(TT) - like pythons pandas .describe()
Because SUMMARY provides different output values depending on the input data type, in general you would end up with a large tabl...

3 years ago | 0

| accepted

Answered
Fullfile code gives error in other system
Your "someone else" is using a MATLAB version older than R2016b: https://www.mathworks.com/matlabcentral/answers/483844-dir-on-...

3 years ago | 0

| accepted

Answered
open some .mat files (whose names are saved inside a cell)
Where C is your cell array of filenames, and assuming exactly one array is saved in each MAT file: D = C; for k = 1:numel(C) ...

3 years ago | 0

| accepted

Answered
Converting partial strings using datetime
"Especially if I want to make it resistant to changes in location (e.g. to Perth or elsewhere in the world), and minimise extra ...

3 years ago | 0

| accepted

Load more