Answered
How to concatenate elements of cell array
Where |C| is your cell array: [C{:}] or horzcat(C{:}) For more info on how this works, read about _comma separat...

9 years ago | 9

| accepted

Answered
find the max value in a struct
Your basic concept of how to do this is okay, you just need to pay more attention to the details, such as the data sizes, and wh...

9 years ago | 0

| accepted

Answered
Spline on matrix where one column contains ONLY NaN
Where |M| is your matrix: >> xo = 1:size(M,1); % old X values. >> xn = [1,2,5]; % new X values. >> idx = ~all(isnan(M...

9 years ago | 0

| accepted

Answered
Choosing between different input parameters in the same script
Use |switch| and some appropriate names for those steel types: switch steel_type case 'type1' e = 0.20; ...

9 years ago | 0

| accepted

Answered
Reduce number of outputs in workspace
*Method One: write a function:* function D = myfun(a) m = size(a,1); D = zeros(m,m); for i = 1:m for j =...

9 years ago | 1

| accepted

Answered
How to group by matrix by row numbers
One way to split into those groups, although it does not preserve the row order, is to use <https://www.mathworks.com/help/matla...

9 years ago | 0

Answered
How to Get a Structure as an Output from a Function?
You did not define your function to have any output: function []=filesort(x) ^^ no output argument! Also you...

9 years ago | 2

| accepted

Answered
How to search and sort strings from a structure efficently?
Dat.standard(1).name = 'x'; Dat.standard(2).name = 'xZ1P'; Dat.standard(3).name = 'x'; Dat.standard(4).name = 'xZ1G';...

9 years ago | 0

| accepted

Answered
Subtract rows in matrix using loop
Use <https://www.mathworks.com/help/matlab/ref/diff.html |diff|>: diff(UVI_all_am,1,1) And stick a row of zeros along th...

9 years ago | 0

| accepted

Answered
What is wrong on my script?
Inside your function |fitness| you obtain the second element of |x| using this line of code: f =x(2); but when you call ...

9 years ago | 1

| accepted

Answered
Good day everyone. Please, how do I convert my .asv file to .m file? Thank you.
Change the file extension from |.asv| to |.m| <https://www.mathworks.com/matlabcentral/answers/85619-what-is-asv-file-in-matl...

9 years ago | 1

| accepted

Answered
I have 100 2D matrix .. After each matrix, I calculate the sum of elements inside it .. I want to see only the matrices with summation result under certain value (such as: 23). How can I do this?
Well, this is trivial if you store your data correctly in *one* array: >> A = randi(8,2,2,100); % one hundred 2x2 matrices ...

9 years ago | 0

Answered
Adding elements from a matrix to different vectors in a loop
You do not need the loops, just use <http://www.mathworks.com/help/matlab/ref/find.html |find|>: [qp,pp] = find(p.');

9 years ago | 1

| accepted

Answered
Is there a way for a script to cd to itself, wherever it may currently reside?
p = mfilename('fullpath') p = fileparts(p); cd(p) but it would not be a very good code practice: * Scripts are an ...

9 years ago | 0

Answered
Passing names of functions to another function with parameters as input in MATLAB
Well, apart from using Object Oriented code, the other obvious method would be to turn those strings into function handles using...

9 years ago | 0

Answered
How to display in GUI
Given a numeric vector, here is one way to generate a string to display: >> vec = [ -1/pi, 0, 1/(3*pi), 0, -1/(5*pi), 0, 1/...

9 years ago | 0

Answered
Sort matrix by datenum
Where |M| is your matrix, use <https://www.mathworks.com/help/matlab/ref/sortrows.html |sortrows|> and its second optional argum...

9 years ago | 0

| accepted

Answered
How do I change the increment in a loop
i = 1:2:N ^ define the step size here! The colon operator is clearly explained in the documentation: <https://www...

9 years ago | 6

Answered
What's the solution?
Here is one easy way, by generating one 3D array |B| and allocating all values of |A| in one go: >> A = [7,4,1;4,5,6;3,6,9]...

9 years ago | 0

| accepted

Answered
Change element in a vector
Without copying the array: >> A = [1,2,4;2,3,5;6,4,6;2,5,6] A = 1 2 4 2 3 5 6 4 6 2 ...

9 years ago | 0

Answered
How to calculate index of minimum value in cell array
>> m1{1,1} = [0.34463,0.3276,0.3615,0.3446,0.3559,0.3389,0.3389,0.3446]; >> m1{1,2} = [0.36723,0.3333,0.3615,0.3615,0.3446,...

9 years ago | 0

| accepted

Answered
How to obtain a numeric vector with the position of elements of an array regarding another array?
Creating numbered variables is not a good code design decision, so the first thing we should do is store that data in nested cel...

9 years ago | 1

| accepted

Answered
How to substitute numbers in a string with repeated strings?
This is easy with a <https://www.mathworks.com/help/matlab/matlab_prog/dynamic-regular-expressions.html dynamic regular expressi...

9 years ago | 0

| accepted

Answered
Images are stored as per the dictionary
Download my FEX submission natsortfiles, which will sort those filenames into alphanumeric order: http://www.mathworks.com/matl...

9 years ago | 0

Answered
how can i read images from a folder in a sequence using loops.
Download my FEX submission natsortfiles, which will sort those filenames into the correct order: http://www.mathworks.com/matla...

9 years ago | 1

Answered
Subtract two matrices each with NaN values in different cells?
>> X = cat(3,A,-B); >> Z = nansum(X,3); >> Z(all(isnan(X),3)) = NaN Z = NaN NaN NaN NaN NaN NaN NaN ...

9 years ago | 0

| accepted

Answered
Function 'subsindex' is not defined for values of class 'cell'.
The problem is simple: |cc.PixelIdxList(i)| is a cell array, and _cell arrays cannot be used for indexing_. The <https://www....

9 years ago | 0

Answered
code not working in function but working in command line line by line
The problem is your function name: function image(...) Do NOT call your function |image|, because |image| is the name o...

9 years ago | 1

| accepted

Answered
How to move the decimal
>> T = [1.3982e-06,1.4056e-06]; >> T * 1e6 ans = 1.3982 1.4056

9 years ago | 0

Load more