Answered
update a string function in matlab
a = 5; b = [4,5]; sprintf('it has happened %d times in the flight, in the %d and %d second',a,b(1),b(2)) A general solution: ...

5 years ago | 0

| accepted

Answered
extracting files having names with the same date from a dataset
Here is one approach, tested on the attached files: P = '.'; % absolute or relative path to where the files are saved S = dir(...

5 years ago | 0

| accepted

Answered
operation in matrix in matlab
"...i want to know the number of times, a matrix has a value greater than 4." The efficient MATLAB approach: a = [3,4,2,5,3,5]...

5 years ago | 0

Answered
configure display of exponential numbers
format shortEng 1e-10*[0.1270,0.1310,0.1120,0.1480,0.1650]

5 years ago | 1

| accepted

Answered
Read and extract specific values from a textfile
The numeric values below are in two matrices, you can use indexing to extract the t, Gh, etc. vectors. format short G str = fi...

5 years ago | 1

Answered
I'm trying to make a function and my if statement isn't working properly
Assuming that mu is scalar: if a(i) >= mu % ^^^ you need this indexing Note that the MATLAB approach would be to get rid of...

5 years ago | 0

| accepted

Answered
Why sometimes a matlab function is called without input arguments?
"I have seen that matlab function like this function dx = some_name(x, u, p) is called as following model = @some_name;" That s...

5 years ago | 0

| accepted

Answered
Store directory listing into loopable structure
The MATLAB approach: P = 'C:\Users\dbhadra\Desktop\MSD\Sensor Mixing\Pr14 Ryan Data\TC2\RT\Closed_Loop'; S = dir(fullfile(P,'*...

5 years ago | 0

| accepted

Answered
How to remove decimals digits from datetime arrays?
Assuming that the goal is to truncate at some precision (which is totally independent of the FORMAT), then this works: T = date...

5 years ago | 0

| accepted

Answered
Error when converting Matlab time (double) to datetime (raw data captured from RealTerm)
"Why the clock time jumps from '05:01:59.971000000' to '05:01:00.230000000' if the double type times are sequential?" Because y...

5 years ago | 1

| accepted

Answered
How to create 4D matrix with several 3D matrix??
C = {all of your N 3D array in one cell array}; A = permute(cat(4,C{:}),[4,1,2,3]); But it would be simpler and more efficient...

5 years ago | 0

| accepted

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

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

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

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

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

5 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(:)

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

5 years ago | 0

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

5 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])...

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

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

5 years ago | 0

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

5 years ago | 1

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

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

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

5 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}(...

5 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','...

5 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])

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

5 years ago | 1

Load more