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...

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...

1 month 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...

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...

1 month 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 = ...

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 = ...

1 month 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...

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...

1 month 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...

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...

1 month 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...

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...

1 month 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')

Create a matrix of HEX number from a file of HEX number separated by a space

S = readmatrix('test.txt', 'OutputType','string')

1 month 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...

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...

1 month 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...

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...

1 month 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...

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...

1 month 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...

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...

2 months 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 ...

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 ...

2 months 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...

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...

2 months 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-...

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-...

2 months 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) ...

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) ...

2 months 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 ...

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 ...

2 months ago | 0

| accepted

Answered

Adding 2D array to 3D array within loop

The robust approach avoiding SQUEEZE is to use PERMUTE, e.g. inside the loop: totalarray(i,:,:) = totalarray(i,:,:) + permute(n...

Adding 2D array to 3D array within loop

The robust approach avoiding SQUEEZE is to use PERMUTE, e.g. inside the loop: totalarray(i,:,:) = totalarray(i,:,:) + permute(n...

2 months ago | 1

Answered

What Unicode characters can be rendered in the Command Window?

The maximum character code that (currently) can be used in MATLAB is: +char(Inf) The value you are attempting to convert is ab...

What Unicode characters can be rendered in the Command Window?

The maximum character code that (currently) can be used in MATLAB is: +char(Inf) The value you are attempting to convert is ab...

2 months ago | 1

| accepted

Answered

Convert 3d cell array into a 3d Matrix

Your cell array contains only symbolic values: S = load('Motormoment_a.mat'); C = S.Ma unique(cellfun(@class,C,'uni',0)) Her...

Convert 3d cell array into a 3d Matrix

Your cell array contains only symbolic values: S = load('Motormoment_a.mat'); C = S.Ma unique(cellfun(@class,C,'uni',0)) Her...

2 months ago | 0

| accepted

Answered

how can compare the variable names of one timetable with many other timetables (quicker)?

Note that if you are checking table k you only need to compare against the remaining k+1:end tables: N = numel(x); for k = 1:N...

how can compare the variable names of one timetable with many other timetables (quicker)?

Note that if you are checking table k you only need to compare against the remaining k+1:end tables: N = numel(x); for k = 1:N...

2 months ago | 0

Answered

create a matrix that keeps only the sequential numbers

S = load('CountArray_A_zoom_select.mat'); A = S.CountArray_A_zoom_select X = diff(A(:,1))==1; Y = [X;0]|[0;X]; B = A(Y,:)

create a matrix that keeps only the sequential numbers

S = load('CountArray_A_zoom_select.mat'); A = S.CountArray_A_zoom_select X = diff(A(:,1))==1; Y = [X;0]|[0;X]; B = A(Y,:)

2 months ago | 0

| accepted

Answered

Convert 1x1 cell array to double

Here with no intermediate table: statsTable = readtable("stats_1-trace_vector_example.csv", 'PreserveVariableNames', true); r...

Convert 1x1 cell array to double

Here with no intermediate table: statsTable = readtable("stats_1-trace_vector_example.csv", 'PreserveVariableNames', true); r...

2 months ago | 1

Answered

I have a problem with plugging values into array variable

firstday = pm25_var(25,114,1,1:24);

I have a problem with plugging values into array variable

firstday = pm25_var(25,114,1,1:24);

2 months ago | 0

| accepted

Answered

how to generate structure member values with only one index data of parent structure .

In lieu of your actually answering my questions here I will presume that both badly-named STRUCT and MEMBER are scalar structure...

how to generate structure member values with only one index data of parent structure .

In lieu of your actually answering my questions here I will presume that both badly-named STRUCT and MEMBER are scalar structure...

2 months ago | 0

| accepted

Answered

How can I parse this textfile with textscan? Delimiter \t not working

"At first I thought, each block would be split into cell array of 5 columns if I use delimiter \t. But the result was not what I...

How can I parse this textfile with textscan? Delimiter \t not working

"At first I thought, each block would be split into cell array of 5 columns if I use delimiter \t. But the result was not what I...

2 months ago | 1

| accepted

Answered

column vector from another vector

vertcat(acd3cd8noly{5,1:end})

column vector from another vector

vertcat(acd3cd8noly{5,1:end})

2 months ago | 0

| accepted

Answered

Store all results obtained from a for loop inside a matrix

The simpler MATLAB approach is to use SUB2IND: matrix = [5,6,14,25; 14,55,44,16; 98,65,34,75; 67,89,21,88]; coord = [1,1; 1,3;...

Store all results obtained from a for loop inside a matrix

The simpler MATLAB approach is to use SUB2IND: matrix = [5,6,14,25; 14,55,44,16; 98,65,34,75; 67,89,21,88]; coord = [1,1; 1,3;...

2 months ago | 0

| accepted

Answered

import to the workspace a .mat file saved in a folder other than pwd

The recommended approach is to use FULLFILE (and to always LOAD into an output variable): S = load(fullfile(folder,file)) Why ...

import to the workspace a .mat file saved in a folder other than pwd

The recommended approach is to use FULLFILE (and to always LOAD into an output variable): S = load(fullfile(folder,file)) Why ...

2 months ago | 0

| accepted

Answered

Why create a 1-by-3 structure array with one field by this way？

"Is it better than this" Not really: both are fragile code and should be avoided. They will both throw errors or produce unexp...

Why create a 1-by-3 structure array with one field by this way？

"Is it better than this" Not really: both are fragile code and should be avoided. They will both throw errors or produce unexp...

2 months ago | 2

| accepted

Answered

How to convert char data to double format?

"The size of the data is [2x72],..." The data you provided is actually a 2x64 char array. "I want to store each element, inclu...

How to convert char data to double format?

"The size of the data is [2x72],..." The data you provided is actually a 2x64 char array. "I want to store each element, inclu...

2 months ago | 0