Réponse apportée
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...

plus de 2 ans il y a | 2

| A accepté

Réponse apportée
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...

plus de 2 ans il y a | 0

Réponse apportée
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...

plus de 2 ans il y a | 0

Réponse apportée
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 ...

plus de 2 ans il y a | 1

Réponse apportée
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

plus de 2 ans il y a | 0

Réponse apportée
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" ...

plus de 2 ans il y a | 0

Réponse apportée
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...

plus de 2 ans il y a | 0

| A accepté

Réponse apportée
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 ...

plus de 2 ans il y a | 1

Réponse apportée
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...

plus de 2 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 2 ans il y a | 0

Réponse apportée
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')); %...

plus de 2 ans il y a | 0

Réponse apportée
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}; ...

plus de 2 ans il y a | 0

| A accepté

Réponse apportée
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...

plus de 2 ans il y a | 1

Réponse apportée
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 ...

plus de 2 ans il y a | 0

| A accepté

Réponse apportée
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)

plus de 2 ans il y a | 0

| A accepté

Réponse apportée
Extracting only certain data from a matrix
Where M is your matrix: X = M(:,1)==3; B = M(X,:)

plus de 2 ans il y a | 0

Réponse apportée
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)...

plus de 2 ans il y a | 0

Réponse apportée
Calculating a mean matrix of a cell array
M = mean(cat(3,A{:}),3,'omitnan')

plus de 2 ans il y a | 0

| A accepté

Réponse apportée
Finding files in directory with two different strings in filename
Use FULLFILE rather than concatenating text together. Here is a simple approach that solves the problem you pose in your questi...

plus de 2 ans il y a | 1

| A accepté

Réponse apportée
How to rename identical variables under one common name?
T = readtable('myData.xlsx') T.Type = regexp(T.Type,'^[A-Z]{4}','match','once')

plus de 2 ans il y a | 1

| A accepté

Réponse apportée
Populate a matrix using the elements of some columns of another matrix as index and other as values
" may have multiple values with the same indices. In my case, I need to add the values with the same index" That is exactly wha...

plus de 2 ans il y a | 0

| A accepté

Réponse apportée
Adjusting the datetick issue.
Do not use deprecated DATENUM or serial date numbers or the like. Use DATETIME (and set the format if required): S = load('m_t...

plus de 2 ans il y a | 1

Réponse apportée
Why can not the 'save' command store a matrix of single precision into a txt file? Warning: Attempt to write an unsupported data type to an ASCII file. Variable 'AA2' not wri
" What's the reason..." Because venerable SAVE does not really offer much functionality when exporting to text file, due to it ...

plus de 2 ans il y a | 0

| A accepté

Réponse apportée
Format display number into table
You can change the variable viewer format in the options: Preferences -> Variables -> Format -> Default Display Format. You ne...

plus de 2 ans il y a | 0

| A accepté

Réponse apportée
Define strings in MATLAB
"I have lots of set and get commands which I need to generate them within a for loop do that I have not to type all of them." D...

plus de 2 ans il y a | 0

| A accepté

Réponse apportée
Hi! Can you help me create a vector containing multiples of 10? like 10^-5 to 10^5?
"Can you help me create a vector containing multiples of 10? like from 10^-5 to 10^5?" Guessing that you really mean integer po...

plus de 2 ans il y a | 1

| A accepté

Réponse apportée
Find the indices of minimum value in each block of a block diagonal matrix
Using BWLABEL as KSSV suggested: S = load('synced_stamped.mat'); M = S.synced_stamp M(isnan(M)) = 0; [X,N] = bwlabel(M,4) F...

plus de 2 ans il y a | 0

Réponse apportée
datetime comparison fails but datenum works
"datetime comparison fails but datenum works" Actually DATENUM fails but DATETIME works. The dates you uploaded have a higher ...

plus de 2 ans il y a | 1

| A accepté

Réponse apportée
Skip folders in a for loop
"How do I skip the dates 26, 27 and 28?" I would just use DIR to get a list of content in the parent folder. For example here i...

plus de 2 ans il y a | 0

| A accepté

Réponse apportée
Strange behavior from readtable
While READTABLE's automagic file format detection is great, the more a file deviates (missing data, lines filled with asterisks)...

plus de 2 ans il y a | 0

| A accepté

Charger plus