Answered
How to divide a 400x800 matrix to 8x8 blocks?
M = rand(400,800); [R,C] = size(M); C = mat2cell(M,8*ones(1,R/8),8*ones(1,C/8))

2 years ago | 0

Answered
I have a matrix. I want to count number of only those zeros which are lying between 2 sets of consecutive nonzero values on each side. How to do? Desired result given below
A general solution requires that: the 3rd value should be empty. therefore e.g. a container array needs to be used. Consider ...

2 years ago | 0

Answered
Increase the number of elements inside a cell
No loop, no concatenation required: A = {'5';'11'}; B = {'7';'19'}; out = [A,B]; % cell 2x2 parameter = 4; out(:,end+1:para...

2 years ago | 0

| accepted

Answered
Splitting Table Based on One Column Value
Use the correct type of indexing. Curly braces returns the table content, not another table: https://www.mathworks.com/help/mat...

2 years ago | 1

| accepted

Answered
How to extract multiple excel tabs into MATLAB
Do not use deprecated XLSREAD. It is very odd that your filename does not have a file extension, I fixed that for you: F = 'C:...

2 years ago | 1

Answered
How to create new rows in a table based on nested cell arrays of different sizes
This is MATLAB, so do not use on concatenation within loops to achieve this task. Better: S1 = load('file.mat'); S2 = load('fi...

2 years ago | 0

| accepted

Answered
unpack cell array of letters to be plugged into individual-cell rows, in a vector
Why are you storing numeric data as text? That must make data processing very awkward: most likely better data design would be t...

2 years ago | 1

Answered
Comparing two tables and replacing categorical column, row wise.
Why are you using a loop for this? MATLAB works best when you work in terms of vectors, matrices, and arrays: T1 = array2table(...

2 years ago | 0

Answered
Need help on the array of matrix.
B = reshape(A,3,[]).'

2 years ago | 1

| accepted

Answered
How to add extension to files using MATLAB
According to a comment you made in another thread, the files have no file extension. The first thing is to check if that is real...

2 years ago | 0

| accepted

Answered
convert a column matrix with many rows into multiple column of equal rows
A = [1;3;2;4;5;8;7;6;12;10] B = reshape(A,[],2) B = [1,8;3,7;2,6;4,12;5,10]

2 years ago | 0

| accepted

Answered
Inquiry about ceil function.
"I understand what ceil function does, however I do not understand why is necessary to sum + 1E-12" In lieu of useful code comm...

2 years ago | 0

| accepted

Answered
create matrix (rx1) with the data obtained from the for loop
"Maybe it is because there are numbers in the name field (not in sequence)? I don't think so." Yes, it is exactly because of th...

2 years ago | 0

| accepted

Answered
Suppose i have a matrix (2x4) A=[1 2 3 4;5 6 7 8] and i want to change it into this matrix [1 2;3 4;5 6;7 8]. How to do that?
When using MATLAB you will do these kind of things quite often. Understand the order of data stored in memory: https://www.math...

2 years ago | 0

| accepted

Answered
combine cells with different size
a = {'ball' , 'cake' , 'ice'}; b = {'home'}; c = {'car','moto'}; d = {'money'}; e = cell(4,0); e(1,1:numel(a)) = a; e(2,1:...

2 years ago | 0

| accepted

Answered
only consider fields that exist within a structure
Generally it is easier to keep data together, rather than split it apart. Do not "extract" all of the fields to separate variabl...

2 years ago | 0

Answered
why readtable create field "D" in the struct "D1"
If there is only one variable in the MAT file (regardless of its extension) and you do not know/care what its name is: C = stru...

2 years ago | 0

| accepted

Answered
Dividing a Square Matrix into Four Distinct Matrices Based on indexing element as well as the last digit
Simpler and more efficient. My answer takes into account my comments here. Assumes no zero, negative, fractional, inf, etc. val...

2 years ago | 1

Answered
Write values of large cell to .inp file
Do not use nested loops! Your approach mixes up nested loops and a format string that prints each line. Better: fmt = repmat(',...

2 years ago | 0

| accepted

Answered
how to create for loop in below formula
Your inefficient approach (with anti-pattern numbered variable names): LP1 = rand; LP2 = rand; LP3 = rand; LP4 = rand; LP5 ...

2 years ago | 0

Answered
Expanding current code to be used on folder of these file types, and changing strings into numbers per file.
Download SIP2NUM from here: https://www.mathworks.com/matlabcentral/fileexchange/53886-scientific-prefix-to-number (this code ...

2 years ago | 0

| accepted

Answered
How to plot weeknumbers (integers) in a graph without leaving gaps for weeks that do not exist
This turns out to be surprisingly difficult without DATETIME et al supporting ISO 8601 weeknumbers. The rules for ISO 8601 week...

2 years ago | 0

Answered
vertcat errors - need a 'workaround' solution
S = load('datatables.mat') T1 = S.C1; T2 = S.R1; C1 = categories(T1.ImpactWind) C2 = categories(T2.ImpactWind) C0 = unique(...

2 years ago | 0

| accepted

Answered
export structs within structs
So many nested scalar container arrays: this is very inefficient data design. Much better would be e.g. one non-scalar structure...

2 years ago | 1

| accepted

Answered
im struggling with this one guys like the oddsum and the rest is undefeatable with me
N = 'S2307605'; % must be character V = N(2:end)-'0' R = rem(sum(3*V(1:2:end))+sum(V(2:2:end)),11) S = struct('S','A':'K','G'...

2 years ago | 0

Answered
split struct based on description
C = {S.SeriesDescription}; S_scout = S(strcmpi(C,'Scout')) S_serie = S(strcmpi(C,'Serie')) S_stand = S(strcmpi(C,'Standard'))...

2 years ago | 0

| accepted

Answered
select, only once, the names present in a struct
C = unique({S.SeriesDescription}) https://www.mathworks.com/help/matlab/matlab_prog/comma-separated-lists.html https://www.mat...

3 years ago | 0

| accepted

Answered
Load data as structure in Matlab App Designer
Here is a simple way to convert the output from UIGETFILE to a non-scalar structure similar to that returned by DIR: [F,P] = ui...

3 years ago | 0

Answered
create a struct with two columns
"How can I do it?" S = struct([]); for k = 1:7 name_char % = '0001'; folder_char %= 'C\.....'; S(k).name = nam...

3 years ago | 0

| accepted

Answered
Read files in a folder with dates on them
The actual solution is to parse the filenames that you gave. Lets create some fake files with fake data: X=1;save Profile_1990_...

3 years ago | 1

| accepted

Load more