Answered
Extracting values from array separated by zeros
V = [0,0,0,0,0,2,3,4,5,0,0,0,0,0,1,1,2,3,0,0,0,0,0,0,4,5,1,2,0,0,0,0]; D = diff([true,V==0,true]); B = find(D<0); E = find(D>...

4 years ago | 0

Answered
1D interpolation over vector of observations with linear extrapolation
The query points do not have to be scalar: interp1(grid, func, obs ,'linear','extrap')

4 years ago | 0

Answered
How to keep rows whose values follow a certain sequence?
Here is an old MATLAB trick that you can use, which still works today: https://blogs.mathworks.com/loren/2008/09/08/finding-pat...

4 years ago | 0

| accepted

Answered
Shortening if/elseif loop for value segregation
What you are doing can be broken into two parts: the first part is generally known as data binning. You can do data binning quit...

4 years ago | 1

| accepted

Answered
How do I multiply digits of a given number?
N = 12345; S = num2str(N); prod(S([1,3])-'0')

4 years ago | 0

Answered
my problem is about @.
f = @(x) x.^2; % ^ ^ you forgot these parentheses q = quad(f,1,2) How to define anonymous functions is explained here: ht...

4 years ago | 1

| accepted

Answered
How to automate .mat file loading
You can use the approaches shown in the documentation: https://www.mathworks.com/help/matlab/import_export/process-a-sequence-o...

4 years ago | 0

| accepted

Answered
Sorting and Re-arranging a text file using Matlab by a specific column
T = readtable('test.txt') T = sortrows(T,'ID') G = findgroups(T.ID); S = groupsummary(T,"ID",{"max","sum"},"Number"); S = re...

4 years ago | 0

Answered
I'm trying to convert date numbers to character dates, I created a vector using datenum and manually entering each date in Y,M,D,H,M,S format, and it works but I hope to find
As Steven Lord and Walter Roberson and the MATLAB documentation recommended, you should use DATETIME objects, which can be plott...

4 years ago | 0

Answered
How to select specific files from all the files in a folder?
This is easy using COPYFILE or MOVEFILE with the appropriate wildcard characters, e.g.: P = 'absolute or relative path to where...

4 years ago | 0

| accepted

Answered
Get the position of the max and min values of a variables
[b,index] = maxk(lat1,5); % ^^^^^ the second output is the index

4 years ago | 0

| accepted

Answered
Program to count the number of letters in a character sentence seems to not count the 58th character.
if char(i)==texte(char(j)) % ^^^^^ ^ get rid of this The code could be simplified using HISTCOUNTS, LOWER, etc...

4 years ago | 0

| accepted

Answered
How read the exact number of decimal digits with readtable from a .csv file?
This imports the data as text, converts to numeric for the filter calculation, and then saves the text. Caveat: it does not pres...

4 years ago | 1

| accepted

Answered
From separate channels to RGB
I am guessing that the image files are actually Truecolor RGB (with all channels identical) rather than true Grayscale (a sadly ...

4 years ago | 0

| accepted

Answered
How change unit8 pixel value to intensity data
https://www.mathworks.com/help/matlab/ref/im2gray.html

4 years ago | 1

Answered
Write a Matlab code to check. .. whether a given number is an amstrong number using functions.
N = 153; S = num2str(N); Z = N==sum((S-'0').^numel(S))

4 years ago | 0

Answered
Load data with varying names
The MATLAB documentation explains how: https://www.mathworks.com/help/matlab/import_export/process-a-sequence-of-files.html Th...

4 years ago | 1

| accepted

Answered
NEED TO READ A FILE AND STORE VALUES
I shortened the file a bit by removing some lines from the middle of those data blocks. opt = {'Delimiter','\t', 'CollectOutput...

4 years ago | 1

| accepted

Answered
Sort Matlab table based on pre-defined order
You could do something like this, where C is that column: D = {'B';'A';'C';'D'}; % the desired order C = {'C';'C';'A';'D';'B';...

4 years ago | 0

| accepted

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

4 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(...

4 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]...

4 years ago | 0

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

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

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

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

4 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,'*...

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

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

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

4 years ago | 0

| accepted

Load more