回答済み
Reading data from .txt files from a folder.
To make debugging unexpected data (sizes, types, values) easier, I usually find it easier to concatenate data after the loop: P...

約3年 前 | 0

| 採用済み

回答済み
Vectorising nested for loops
S = load('data.mat') list = S.list tdat = S.table_data k=0; out0 = struct('idx',[],'count',[],'size',[]); for i = 1:size(...

約3年 前 | 1

回答済み
Matlab not recognizing 'fit' function
Have you or any third-party function or toolbox made any changes to the MATLAB search path? Call https://www.mathworks.com/help...

約3年 前 | 1

| 採用済み

回答済み
Remove null rows from a structure before converting to table
S = struct('A',{[],[],1},'B',{[],[],2}) X = arrayfun(@(s)any(structfun(@isempty,s)),S); T = struct2table(S(~X))

約3年 前 | 0

| 採用済み

回答済み
readmatrix ignores the first line of the data file
You can specify the RANGE as the starting row: M = readmatrix('sample.txt', 'ConsecutiveDelimitersRule','join', 'Range',1) I n...

約3年 前 | 1

| 採用済み

回答済み
Sort two array in the same way, but only one in size order
"The problem now is that I want the same rows that changed for x should be changed for y. " It is not a problem, because when y...

約3年 前 | 1

| 採用済み

回答済み
Sorting vectors into a 3-D grid efficently
Perhaps something like this. The elements of M need to be valid indices, which you can achieve using basic arithmetic operations...

約3年 前 | 1

| 採用済み

回答済み
Rewriting a file?
https://www.mathworks.com/help/matlab/ref/writelines.html Tip for the future: you are already using READLINES, so scroll right ...

約3年 前 | 0

回答済み
How can I separate individual years from a timetable?
S = load('DateStamp.mat') T = S.DateStamp [G,Y] = findgroups(T.date.Year); X = arrayfun(@(x)find(x==G), 1:max(G), 'uni',0); ...

約3年 前 | 1

| 採用済み

回答済み
Understanding about stacking in MATLAB
"My query is what does the term stacking indicates..." MATLAB does not use the term "stacking" to refer to these kinds of opera...

約3年 前 | 0

| 採用済み

回答済み
How to rearrange a row vector into a pair wise column vector?
"I am sure there is a nice loop to do this, but I can't find a solution." This is MATLAB, so loops are not required: v = 1:21 ...

約3年 前 | 0

| 採用済み

回答済み
MATLAB poems -- let's hear 'em!
In MATLAB we write lines of code For solving problems, it's our abode With matrices and arrays We handle huge data trays And...

約3年 前 | 0

回答済み
Replace specific elements in strings
Here are two approaches: A = ["America (New York)"; "America (Manhattan)"; "Italy (Rome)"] B = strrep(strrep(A,' (',' - '),')'...

約3年 前 | 0

回答済み
Behavior with unspecified output arguments
"Has it always been this way?" Yes. Several MATLAB functions from waaaay back in the past use exactly this feature. For exampl...

約3年 前 | 1

| 採用済み

回答済み
How can I get the return of a constructed function as an array?
That is not how MATLAB works. Your code defines a matrix of zeros, but then you do nothing with that variable and simply replace...

約3年 前 | 0

| 採用済み

回答済み
Vectors of seeming identical length, are supposedly not equal in length, how to fix?
Read the FITGAUSS documentation: https://www.mathworks.com/matlabcentral/fileexchange/7489-fitgauss The order of your input ar...

約3年 前 | 0

| 採用済み

回答済み
Creating an augmented matrix a set of matrices
A = cat(3,[1,3;0,1],[1,1;1,1],[0,0;0,0]); C = num2cell(A,1:2); X = 1+tril(toeplitz(1:numel(C))); C = [{zeros(2)};C(:)]; M = ...

約3年 前 | 1

| 採用済み

回答済み
find the closest datetime
I have a datetime column with the format HH:mm:ss.SSSS and for which I'm loooking for the closest datapoint to a time in a forma...

約3年 前 | 0

| 採用済み

回答済み
How to list all tasks in a table and sum up total time spend on each?
You can do this in just a few lines of code. Don't fight MATLAB with multiple nested loops! The data would be so much easier to...

約3年 前 | 2

回答済み
How to put value from one matrix into another matrix
A = [3:42;rand(1,40)].' B = [6,45,18,24,33;5,12,17,23,32;4,11,16,22,31;3,10,15,21,30] R = nan(size(B)); [X,Y] = ismember(B,A(...

約3年 前 | 0

回答済み
How to find the order of the power of A matrix?
A = [1,0,1;1,1,0;1,0,0]; B = A; for n = 2:5 B = mod(B*A,2); if isequal(B,eye(3)) break end end n B

約3年 前 | 1

回答済み
How to loop over a structure in matlab
As far as I can tell, this is your data structure (for simplicity I will define only two field Names, but the code works for any...

約3年 前 | 0

| 採用済み

回答済み
Rebuilding a 3D matrix
A1 = A(:,:,[2,5,7]); A2 = A(:,:,[1,6,10]); A3 = A(:,:,[3,4,8,9]); .. change values B = nan(10,10,10); B(:,:,[2,5,7]) = A1; ...

約3年 前 | 1

| 採用済み

回答済み
How to save a vector from each iteration in a loop in a matrix?
Take a closer look at your preallocation. What does SIZE(..) return?: size(230,300) so your preallcoation zeros(size(230,300)...

約3年 前 | 1

| 採用済み

回答済み
Cropping several images inside a for delivers empty cells
for K=1:10 % <- uppercase I_{k}=imcrop(I{k},RECT); end % ^ lowercase ^ MATLAB is case-sensitive, so you need to make th...

約3年 前 | 0

| 採用済み

回答済み
Reorganization of data in matrix
You could DOWNLOAD Jos' excellent PADCAT: https://www.mathworks.com/matlabcentral/fileexchange/22909-padcat and use it somethi...

約3年 前 | 0

| 採用済み

回答済み
How to extract the months from a datetime table?
S = load('DateStamp.mat') T = S.DateStamp; T.month = T.date; T.month.Format = 'MMMM' But I am guessing that your actual goal...

約3年 前 | 1

| 採用済み

回答済み
How to save results matrix in multi dimensional matrix?
In general with MATLAB it is easier (even if more verbose) to iterate over indices rather than over data. For example: tV = 25...

約3年 前 | 0

回答済み
How to read a specially structured data file
fid = fopen('test.txt','rt'); mat = fscanf(fid,'%f',[19,Inf]).'; fclose(fid); display(mat)

約3年 前 | 2

| 採用済み

回答済み
How can I convert log(-1) to complex number
log10(-1)

約3年 前 | 0

| 採用済み

さらに読み込む