Answered
how to parse different sections of text file into separate matrices
TEXTSCAN makes this relatively easy: out = {}; fmt = repmat('%f',1,7); opt = {'CollectOutput',true}; fid = fopen('test.txt')...

4 years ago | 0

| accepted

Answered
Question about using ismembertol function
"The result should show that A has not been found in B... You do not explain why you think that. I am guessing that you misunde...

4 years ago | 2

| accepted

Answered
How to get two arrays from .txt file?
MATLAB does not have ragged arrays, you could import them as vectors, e.g.: format short G str = fileread('arrays2.txt'); tmp...

4 years ago | 1

| accepted

Answered
Loop through field variables named AnB, where n is an arithmetic value
for ii = 1:9 fnm = sprintf('B1N%dFy',ii); Stdwind_pstill.OutputChannels(k).(fnm) end https://www.mathworks.com/help/...

4 years ago | 0

| accepted

Answered
How to split binary cells and convert them to dec?
More efficient than using CELLFUN: C = {'0100101000101000';'0100101000101000';'0100101000101000';'0100101000101000'} V = [4,2,...

4 years ago | 0

Answered
I want to make a time series from 2016/1/1 00:00 to 2016/12/30 00:00 with one hour difference
V = datetime(2016,1,1):hours(1):datetime(2016,12,20); V = V(:)

4 years ago | 1

| accepted

Answered
access multiple csv files from different folder
This should get you started. Because you did not upload any sample files I could not test it, therefore it will probably not wor...

4 years ago | 0

Answered
When I run a script, it prints the entire file.
echo off

4 years ago | 0

Answered
How to make two seperate list of files from one list of files?
all_files = dir(fullfile(Folder, '*.mat')); green_files = all_files([2,3,7,8,12,13]) red_files = all_files([4,5,9,10,14,15])...

4 years ago | 0

| accepted

Answered
Moving Bulk MATLAB file to different folders
P = 'absolute or relative path to where the files are saved': S = dir(fullfile(P,'*.mat')) for k = 1:numel(S) [~,N,~] = f...

4 years ago | 0

| accepted

Answered
Reading all values as a string from excel file
In Excel dates are stored as serial date numbers, so what you are getting is the raw data. The best solution is to use READMATR...

4 years ago | 0

Answered
Using mat2cell
M = rand(2840,256); C = mat2cell(M,142*ones(1,20),256)

4 years ago | 1

Answered
Meshgrid or other structure?
Simpler: M = hankel(-96:4:96)

4 years ago | 1

| accepted

Answered
How do I convert a 2d matrix to a 3d matrix and vice versa efficiently?
format compact A(:,:,1) = [1,2;3,4;5,6]'; A(:,:,2) = [10,20;30,40;50,60]'; A(:,:,3) = [11,21;31,41;51,61]'; A(:,:,4) = [100,...

4 years ago | 0

| accepted

Answered
How to find the index of the minimum value in a matrix.
Where M is your matrix: [R,C] = find(M==min(M(:))) or [~,X] = min(M(:)); % or [~,X] = min(M,[],'all','linear'); [R,C] = ind2...

4 years ago | 1

Answered
Get all unique combinations of 2 columns from a table
V = {'Item1','Item2','Item3','Item4'}; T = table(1, 5, 7 ,10, 'VariableNames',V) X = nchoosek(1:numel(V),2); D = diff(T{:,V}(...

4 years ago | 1

| accepted

Answered
How do I transform this format 202007011030 (2020 07 01 10:30) into a readabel format?
You can easily import as DATETIME, no need to import as text nor fiddle around with text: fid = fopen('Fehmarn_Wind_date.txt','...

4 years ago | 0

| accepted

Answered
How to create a 3D matrix from subtracting 2D matrices (like creating 2D matrix from subtracting vectors)?
C = permute(A,[1,3,2]) - permute(B,[3,2,1])

4 years ago | 1

| accepted

Answered
Reading text file data with different data formats
Move the "header" to the top: txt = fileread('sample test data.txt'); [hdr,spl] = regexp(txt,'^#[^\n]+','match','split','linea...

4 years ago | 1

Answered
Use of assignment '=' in plot command?
That name-value sytnax was introduced in R2021a: y=1:10; plot(y,'.-',linewidth=2) % ^^^^^^^^^^^ this syntax introdu...

4 years ago | 0

| accepted

Answered
Write sections of a long string as new lines in a text document
sub = 'XYZYXYZYZYZXYZYXYZ0XYXYXYX'; tmp = split(sub,'0'); fprintf('%s\n',tmp{:})

4 years ago | 0

| accepted

Answered
How to save a matrix data with a concatenated variable name?
It is simpler and more efficient to use a structure: C = {'PrimSpeed','SecSpeed'}; S = struct(); for k = 1:numel(C) ...

4 years ago | 0

| accepted

Answered
Find corresponding element in same row as given value in matrix
Assuming that A and B are you matrices, and that the Y values are in the second columns: [valA,idx] = max(A(:,2)) valB = B(idx...

4 years ago | 0

| accepted

Answered
What is the best practice to recursively extract data from a nested structure in matlab?
S=struct(); S.case='1'; S.type='A'; S.values.model1.case='2'; S.values.model1.type='C'; S.values.model1.values.mission.case...

4 years ago | 1

| accepted

Answered
Identifying numbers within a long string containing multiple occurrences of text and numbers in one row
Simpler and gives the requested output: str = 'x y z p (Pa)...

4 years ago | 0

| accepted

Answered
Read CSV with yyyyMMddhhmmss and group months
Here is one way to group by month only, ignoring empty lines of the CSV file: str = fileread('sample.csv'); tkn = regexp(str,'...

4 years ago | 0

| accepted

Answered
using mat2cell
Using NUM2CELL would be simpler: C = num2cell(M,1) But if you insist on using MAT2CELL: C = mat2cell(M,1001,ones(1,10))

4 years ago | 0

Answered
how can i negative all value in a matrix except diagonal?
M = [13.333,5,0,5,3.3333,0;5,27.333,4,10,3.3333,5;0,4,17.846,0,3.8462,10;5,10,0,17.5,2.5,0;3.3333,3.3333,3.8462,2.5,16.346,3.333...

4 years ago | 1

| accepted

Answered
How to unfold/concatenate a 3D Matrix?
Making some guesses about the order you want, where A is your array: B = reshape(permute(A,[1,3,2]),[],21)

4 years ago | 0

| accepted

Answered
Problem in properly creating a structure to store data
The simple and efficient approach: P = 'absolute or relative path to where the files are saved'; S = dir(fullfile(P,'*.txt'));...

4 years ago | 0

| accepted

Load more