Answered
How to Concatenate struct arrays efficiently
Your very slow code is due to that your variable |finalData| changes size on every loop iteration, forcing MATLAB to move it in ...

8 years ago | 2

| accepted

Answered
From 2D data to a 3D matrix
S = dir('7528_00*.txt'); N = numel(S); A = nan(128,128,N); for k = 1:N S(k).name A(:,:,k) = ... load yo...

8 years ago | 0

Answered
How can I set the file name as my title name in a subfolder for numerous plots
The <https://www.mathworks.com/help/matlab/ref/title.html |title|> |'String'| property may be a cell array, string array, or a c...

8 years ago | 0

| accepted

Answered
How do I average the rows of a matrix in 10 groups inside a cell array?
Inside the loop of my <https://www.mathworks.com/matlabcentral/answers/402276-how-to-filter-rows-in-all-slices-of-a-3d-matrix-wi...

8 years ago | 0

| accepted

Answered
How to filter rows in all slices of a 3D matrix with respect to multiple columns?
Use a preallocated cell array to store the output: N = size(weekdata,3); C = cell(1,N); for k = 1:N idx = week...

8 years ago | 0

| accepted

Answered
Read files in a specific order
Download my FEX submission natsorfiles, which was designed to fix the exact problem that you are having. Use it to simply sort t...

8 years ago | 3

| accepted

Answered
File Exchange: Why are some characters, such as "²", omitted in the code shown in the "Functions" tab of a file?
_"I would like to know which characters I should avoid to use."_ If you want to write truly universal files that work for eve...

8 years ago | 2

| accepted

Answered
How to find the neighbors of each element in a matrix
Here is a simple method using <https://www.mathworks.com/help/matlab/ref/conv2.html |conv2|>: >> A = [3,4,8,6;1,6,9,0;2,5,7...

8 years ago | 8

| accepted

Answered
Problem with concatenation, help me
[~,arquivo] = fileparts(arquivo); arquivo = sprintf('%s%d.FIL',arquivo,x) But there is no point in calling |fileparts| r...

8 years ago | 0

Answered
Navigating a Structure Using Cell Arrays in a For Loop
You are using the wrong brackets: you need to use |{}| to get data out of a cell array, e.g.: surface(a.(scans{j}).rel_X, ....

8 years ago | 0

| accepted

Answered
Selecting nearest value of matrix from different matrix
Assuming that you want the "nearest" in a Euclidean sense: >> A = [2,4;4,27;21,49;18,21;37,38;44,47]; >> X = [21,22;41,4...

8 years ago | 0

| accepted

Answered
How to get data from a variable number of Edit Text box in Matlab GUI ?
You will need to pass the array of handles |edit| to the callback/function where you want to access them all, and either: * l...

8 years ago | 1

| accepted

Answered
how to collect variables in an aray in for loop?
Just use indexing with a preallocated variable: function out = close_point(p0,p1,p2,p3) vec = 0:0.1:1; out = nan(size...

8 years ago | 1

Answered
Efficient operation on individual matrix rows
_"I could use a "for loop" which is quite slow:"_ The problem is not the |for| loop, but the fact that you expand the array |...

8 years ago | 2

| accepted

Answered
Populate pyargs() arguments with the contents of a string cell array.
tmp = a.'; pyargs(tmp{:})

8 years ago | 0

Answered
Deleting rows of matrix from the rows of other matrix with different dimension
The simplest solution is to use <https://www.mathworks.com/help/matlab/ref/ismember.html |ismember|> with its |'rows'| option: ...

8 years ago | 0

| accepted

Answered
creating time vector ?
<https://www.mathworks.com/help/matlab/matlab_prog/generate-sequence-of-dates-and-time.html> <https://www.mathworks.com/help/...

8 years ago | 1

| accepted

Answered
elseif in not executing. how to rectify this.
The syntax |A<X<B| does not do what you think it does. You will need to use two comparisons: elseif Y_min<Y(i) && Y(i)<Y_m...

8 years ago | 0

Answered
I want to map a matrix column's cells to another matrix based on matched respective column's cell
C = A; C(:,3) = B(A(:,1),2) This assumes that the first column of |A| are positive integers corresponding to the rows of...

8 years ago | 0

| accepted

Answered
How do I create multiple for loops depending on the array size?
A recursive function is the obvious solution, although this depends on whether you count recursive functions as being _"a good w...

8 years ago | 1

Answered
How to correct this code?
The basic problem is that you assume that structure |A| has atleast 1995 elements, but there is nothing in your code to ensure t...

8 years ago | 0

Answered
Why am i getting error too many input arguments ?
Here is the function defintion of |eulode| (including superfluous space between function name and parenthesis): function [t...

8 years ago | 0

| accepted

Answered
extend a Matrix in every iteration
A = randi(9,10,10,10); [X,Y,Z] = ind2sub(size(A),1:numel(A)); mat = repelem([X(:),Y(:),Z(:)],A(:),1,1); but I don't s...

8 years ago | 0

| accepted

Answered
reshape and sum multi-dimensional matrix
Where |A| is your array: A(:,:,1:2:end) + A(:,:,2:2:end)

8 years ago | 1

| accepted

Answered
Function 'subsindex' is not defined for values of class 'ss'
*Problem:* You have named some variable |mpc|: mpc.delta_gain = ... which means that you cannot call the <https://www.ma...

8 years ago | 0

| accepted

Answered
Show variable value of subfunction in workspace.
_"When i run main function workspace shows only main function's variable value, not shows variable value that are in the subfunc...

8 years ago | 1

Answered
Combining cell array and double vector into sprintf
You don't need a loop at all, it is simpler without one: str = {'aa','bb','cc'}; vec = 1:3; tmp = [str;num2cell(vec)]...

8 years ago | 2

Answered
Vectorizing 2 nested loops
>> R = [1,2,3,4]; >> (0:3).' * (1:numel(R)) + R ans = 1 2 3 4 2 4 6 8 3 6 9...

8 years ago | 0

Answered
assign a variable using a position changed function?
Forget about what you can see in the base workspace. It does not help you, because the workspace where you try to _use_ that val...

8 years ago | 1

| accepted

Answered
saving an image in a specific folder
Use <https://www.mathworks.com/help/matlab/ref/uiputfile.html |uiputfile|> to get the file name and path, e.g. where |I| is your...

8 years ago | 0

| accepted

Load more