Answered
How to sort folders in imageDatastore?
https://www.mathworks.com/matlabcentral/answers/416241-how-to-sort-the-files-obtained-by-imagedatastore

6 years ago | 0

Answered
Why I the data processed by the matlab is wrong, it reports three wrong results,what is the reason?All the data and .m files are included ,who can help me?
opt = {'CollectOutput',true }; [fid,msg] = fopen('tem-009.out','rt'); assert(fid>=3,msg) str = ''; while ~strncmp(str,'-',1)...

6 years ago | 0

Answered
For loop in function handle
You can simply store function handles in a cell array of any size and use cellfun. No loop required. >> C = {@sin,@sqrt,@pow2};...

6 years ago | 1

Answered
Changing elements of vector with matrix
No loop required: >> v = 1:numel(a); >> x = any(v>=b(:,1) & v<=b(:,2), 1); % requires MATLAB >=R2016b >> a(x) = 1 a = 1 ...

6 years ago | 1

| accepted

Answered
Merge files with the same prefix.
This should get you started (untested, but gives an outline of how you could do this): D = 'path to the folder where the files ...

6 years ago | 0

| accepted

Answered
How to sort one array based on another of a different size
As Rik wrote, the MATLAB solution is to use ismember, e.g.: >> A = {'a','a','b','c','c','d','d','d','d','e','e'}; >> B = {'d',...

6 years ago | 2

| accepted

Answered
Select first n nonzero elements in each row of matrix
Linear indexing does this simply and efficiently. The trick is to work down the columns, which requires transposing: >> A = [1,...

6 years ago | 0

| accepted

Answered
What does the varargin function do and what does varargin{:} mean?
"What does the varargin function do..." varargin is not a function, it is a cell array which contains any number of optional i...

6 years ago | 0

| accepted

Answered
Break command doesn't stop the For loop
"Can anybody please explain me why the 'break' command doesn't work in the following code?" Explanation: The reason is because ...

6 years ago | 1

| accepted

Answered
Reading multiple values from an n*1 cell array.
The most efficient way: >> C = {'3.7482.85813621.44775413.853117-9.113155'; '3.7492.86975821.44393913.816126-9.117885'}; >> M ...

6 years ago | 1

| accepted

Answered
Formatting the JET colormap
The colormapeditor changes the colormap of the current figure. It does not save or store the colormap in any way. You will most...

6 years ago | 1

| accepted

Answered
Get textscan to sort the rows as matrices and columns as cells
opt = {'Delimiter',',', 'CommentStyle','@', 'CollectOutput',true}; [fid,msg] = fopen('assignment1.txt','rt'); assert(fid>=3, m...

6 years ago | 0

| accepted

Answered
How to use multiple variables in a name structure
The most efficient approach is to use sprintf (and is what experienced MATLAB users would do): for k = ... fig_name = spri...

6 years ago | 0

Answered
Datetime conversion input format
According to the datetime documentation, the correct format characters for times are: hours: 'HH' or 'hh' (for 24/12 hour clock...

6 years ago | 0

| accepted

Answered
Extract rows in a Matrix based on column values of another Matrix.
The standard MATLAB approach to this common task is to use the second output of ismember, e.g.: >> [X,Y] = ismember(p,q(:,1)); ...

6 years ago | 1

| accepted

Answered
A complicated matrix manipulation
Try this reasonably "simple and efficient way": r = size(A,1); x = nan(r,1); for k = 1:r r1 = find(A(1:k,1),1,'last'); ...

6 years ago | 1

| accepted

Answered
Replacing specfic numbers in string
>> substr = {'B0.2Si0.05'}; >> numarray = [0.18432,0.04608]; For one element of the cell array substr: >> spl = regexp(substr...

6 years ago | 2

Answered
Load stored handles data to an other function
"I think that something is missing in this ligne" Actually you already have too much on that line. Try this: DataNeed = handle...

6 years ago | 0

| accepted

Answered
How can we convert a datetime into a string that represents a Unix timestamp in nanoseconds?
Warning: this answer delves into undocumented features of the datetime object and relies on my own wild speculation that may be ...

6 years ago | 1

| accepted

Answered
What does '* *' mean in matlab?
The double asterisk tells dir to recursively search the provided path, the documentation explains it with "and dir **/*.txt list...

6 years ago | 1

Answered
Incorrect Logical Condition Statement
Leg = 'L'; %change between L and R vnm = sprintf('knee_flex_%s',lower(Leg)); Tables.(vnm) https://www.mathworks.com/help/matl...

6 years ago | 0

Answered
find the multiple max values
Where M is your matrix: >> U = unique(M(:)); >> X = ismember(M,U(end-2:end)); >> M(~X) = 0 M = 0 0 44 0 44 ...

6 years ago | 0

Answered
Import name/value parameters from a text file to a struct (or cell array)
As far as I am aware there isn't anything inbuilt. But you can do something like this: >> str = fileread('myparamfile.txt'); >...

6 years ago | 0

| accepted

Answered
Error using vertcat - Dimensions of arrays being concatenated are not consistent
R2 = [3; 4; -3.5; 3.5; 3.5; -3.5; -5; -5 5; 5]; % ^ missing semi-colon

6 years ago | 1

| accepted

Answered
interpolation for a matrix per row
You forgot the indexing here: interp1(t0,(RESULTS.Kinematics(j).data),t1,'linear') % ^^^ missing

6 years ago | 0

| accepted

Answered
populate matrix columns based on a vector of index vector
>> X = (1:5)>=B(:); % requires >=R2016b, for earlier versions replace >= with BSXFUN >> [R,~] = find(X); >> A(X) = C(R) A = ...

6 years ago | 0

| accepted

Answered
How to access data in a nested structures
"Is this the correct way?" The usual MATLAB way is to use two lines, e.g.: tmp = [a.b]; out = [tmp.c]; "Why does this not wo...

6 years ago | 0

| accepted

Answered
How to Save multiple results into one array
n = numel(x); xvalue = zeros(2,n); for ii = 1:n xvalue(:,ii) = mink(abs(Lx-x(ii)),2); end xvalue = xvalue(:).'

6 years ago | 1

| accepted

Answered
pre allocating triple loops
n = numel(L); c = cell(n,n,45); for ii = 1:n for jj = 1:n for kk = 1:45 c{ii,jj,kk} = cross...

6 years ago | 0

| accepted

Answered
Can I change this?
The most efficient solution is likely to be >> X = [1,1,1,0,1,0,0,0,1,0]; >> A = sprintf('%u',X) A = 1110100010

6 years ago | 1

Load more