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

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

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

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

3 years 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,:)

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

3 years ago | 1

Answered
I have a problem with plugging values into array variable
firstday = pm25_var(25,114,1,1:24);

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

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

3 years ago | 1

| accepted

Answered
column vector from another vector
vertcat(acd3cd8noly{5,1:end})

3 years 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;...

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

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

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

3 years ago | 0

Answered
Solving Matrix Index Problem
The simple and efficient approach is to use MTIMES: M = [1,0,0,0;0,1,0,0;0,2,1,1] % any number of rows V = [0.25;0.1;0.05;0.01...

3 years ago | 0

Answered
Switch Case or if-else?
"Switch statement cannot judge the range of R. It may be possible but it must be very tricky." switch true case R <= 1.2 ...

3 years ago | 1

Answered
Switch not recognizing that 0 is greater than -1
x = 0; switch true case x<-1 y=1 case x<=2 y=x^2 otherwise y=4 end

3 years ago | 0

Answered
How to convert serial number to date number
The CMEMS documentation gives several possible time units, one of them is % julian_day_unit = "days since 1950-01-01 00:00:00" ...

3 years ago | 0

Answered
Reading multiple csv file from multiple folder
P = 'absolute or relative path to the main folder'; S = dir(fullfile(P,'*','*.csv')); for k = 1:numel(S) F = fullfile(S(k...

3 years ago | 0

| accepted

Answered
how insert array in field struct
"it's possibile to avoid loop?" Does A already exist or not? Your question does not make this clear... here are both cases: Z ...

3 years ago | 1

Answered
Content of table not fully displayed
It is unclear why you are storing a cell array in a table with only one variable... why not just the cell array? S = load('Slee...

3 years ago | 0

| accepted

Answered
I want to know the process of changing the array to table. Too many table variables because there are too many arrays.
The simple solution is to use CELLSTR, which gives ARRAY2TABLE the cell of char vectors that it requires: M = (1:5).'*[1,10,100...

3 years ago | 0

Answered
Cropping and saving images: "unable to perform assignment because the size of the left side is 825-by-1081 and the size of the right side is 450-by-601."
% specify folder with uncropped images P = '/Users/greencrystal19/Documents/MATLAB/numframe'; S = dir(fullfile(P,'*.tif')); %...

3 years ago | 0

Answered
Datetimes in table not displayed
C = {datetime(2021,1,1:2);datetime(2022,2,3:6);datetime(2023,3,7:9)} D = NaT(numel(C),0); for k = 1:numel(C) V = C{k}; ...

3 years ago | 0

| accepted

Answered
error "Error in untitled (line 9)"
The ODE45 documentation states that its first input argument must be a function handle: https://www.mathworks.com/help/matlab/r...

3 years ago | 1

Answered
convert arraycell in array string
"it's possibile to convert in string?" Probably. I am guessing that you want something like this: C = {1;[2,34];[56,7,89]} F ...

3 years ago | 0

| accepted

Answered
How to rearrange data to a given decreasing rank order
A = [4,20,60,40,5]; X = [1,2,3,5,4]; B = sort(A,'descend'); B = B(X)

3 years ago | 0

| accepted

Answered
Extracting only certain data from a matrix
Where M is your matrix: X = M(:,1)==3; B = M(X,:)

3 years ago | 0

Answered
Calculate the average of each matrix block
Here are some simple MATLAB approaches: A = repmat([1,2,3,4,1,2,3,4,1,2,3,4,7,6,5,4],16,1) M = mean(permute(reshape(A,4,4,4,4)...

3 years ago | 0

Answered
Calculating a mean matrix of a cell array
M = mean(cat(3,A{:}),3,'omitnan')

3 years ago | 0

| accepted

Load more