Answered
How can I remove the ranges from a specific column vector?
>> vec = [1;0;2;1;9;8;0;0;4;2;3;3;5;1;1;0;3;2;0;0;0;0;0;0]; >> tmp = reshape(vec,12,[]) tmp = 1 5 0 1 ...

8 years ago | 2

| accepted

Answered
Find indices of one array in another array.
The simplest solution is to use <https://www.mathworks.com/help/matlab/ref/ismember.html |ismember|>: >> A = [1 1; 1 2; 2 2...

8 years ago | 2

Answered
What is the function for varargin?
Do NOT use |varargin| _outside_ of any function: it only works _inside_ of a function. Call your function like this: quive...

8 years ago | 0

Answered
Extrapolation gives wrong values when using interp1
_"Extrapolation gives wrong values when using interp1"_ |interp1| is giving the right value. The problem is simple: the la...

8 years ago | 4

| accepted

Answered
Find the first and last elements of consecutive values in a vector
It is easy to identify the first and last elements of consecutive sequences of values: >> a = [10 11 12 19 21 25 29 30 31 3...

8 years ago | 4

| accepted

Answered
How to arrange three vectors into a new vector in specific order?
Simpler: reshape([A1,A2,A3].',[],1)

8 years ago | 0

Answered
How to generate integer random numbers of specific range including all numbers between the range?
This is MATLAB, so is not required to use a |for| loop! It is so simple to generate multiple random permutations of the vector |...

8 years ago | 1

Answered
Find length of a structure element and remove them according to length?
Simpler: len = arrayfun(@(s)numel(s.I),output); output(len>100) = [] Or simplest: len = cellfun('length',{output...

8 years ago | 2

Answered
How do I locate all ones in a binary array and change all adjacent elements to ones?
One simple way, where |V| is your vector: [0;V(1:end-1)] | V | [V(2:end);0] or you could use <https://www.mathworks.com/...

8 years ago | 1

| accepted

Answered
How do you index an array inside an array of structures?
tmp = vertcat(s.field); tmp(:,2)

8 years ago | 3

Answered
How to fprintf of the array of floating-point numbers
Of course there is no correct answer because these are binary floating point values, but here is one solution that gives the "le...

8 years ago | 0

| accepted

Answered
Trying to select multiple sections in an array where the sections are separated by constant size
>> arr = zeros(8,3); % or use reshape >> arr(5:8,:) = 1; >> arr = reshape(arr,1,24) arr = 0 0 0 0 1 1...

8 years ago | 0

| accepted

Answered
My function is only giving me one output
Make sure that you call it with the correct number of output arguments, e.g.: [BeamWeightN,BeamWeightN_X,FB_X,FB_Y,FA_Y,Err...

8 years ago | 1

Answered
Please your help is needed. I have the following 3-D array and would like to sum the values in second column and the third column based on their index values in frist column.
You could use <https://www.mathworks.com/help/matlab/ref/unique.html |unique|> and <https://www.mathworks.com/help/matlab/ref/ac...

8 years ago | 0

Answered
IF statement yields no output
Instead of this: CHOICE(i) == (511 || 512) you need this: CHOICE(i)==511 || CHOICE(i)==512 Following the rules f...

8 years ago | 0

| accepted

Answered
I like to import a string with multiple pathnames
<https://www.mathworks.com/help/matlab/ref/uigetfile.html |uigetfile|> does not return strings, it returns a cell array of char ...

8 years ago | 0

Answered
could anyone help me how the numbers can be separated if they are joined together
General solution: >> num2str(54)-'0' ans = 5 4

8 years ago | 1

Answered
why i'm getting this error?
This line m(i,:) = a0 + ... The LHS references 500 elements (because |m| has size 4x500), whereas the RHS has size 1x250...

8 years ago | 0

| accepted

Answered
Find and convert negative number strings
Use <https://www.mathworks.com/help/matlab/ref/str2double.html |str2double|>: >> str = 'Reference Level -50 fieldB'; >> ...

8 years ago | 0

| accepted

Answered
Save structure in matlanb
_"but it seems that it does not work properly"_ It does exactly what the <https://www.mathworks.com/help/matlab/ref/save.html...

8 years ago | 0

| accepted

Answered
How to compare a vector with a matrix rows ?
It is actually very efficient to use <https://www.mathworks.com/help/matlab/ref/strfind.html |strfind|> to locate an exact seque...

8 years ago | 1

Answered
Sort files based on last part of file name
Both <https://www.mathworks.com/matlabcentral/fileexchange/47434-natural-order-filename-sort |natsortfiles|> and <https://www.ma...

8 years ago | 0

| accepted

Answered
linear interpolation code - interp1
_"It is possible to access the source code of the function 'interp1,"_ I doubt it, and even if you could get a copy it would ...

8 years ago | 0

Answered
I want to save variables from a nested function into the parent function workspace so that I can use these variables again in another nested function. How do I do this?
The whole point of nested functions is that you don't have to pass data as input/output arguments. All you need to do is define ...

8 years ago | 0

Answered
number of times consecutive values occur
Using basic MATLAB commands: >> X = [ 1 1 1 1 0 1 1 0 1 1 0 1 1 0 0 1 1 1]; >> D = diff([0,X,0]); >> V = find(D<0)-fi...

8 years ago | 0

| accepted

Answered
How to concatenate an array of numbers without for loop
>> A = [1,2,3]; >> str = sprintf(', %d',A); >> str = sprintf('(%s)',str(3:end)) str = (1, 2, 3)

8 years ago | 1

| accepted

Answered
Load text file with open braket ( )
It is much more efficient to import the data using a numeric format (rather than as a string and doing post-processing as you ar...

8 years ago | 0

Answered
How can I correctly use if and elseif?
I guess that some of the inputs are non-scalar, in which case you should use indexing: function tk = time(t,toe) tk = t-...

8 years ago | 0

Answered
datenum seconds within minutes
You are using the wrong format characters: the <https://www.mathworks.com/help/matlab/ref/datenum.html |datenum|> help clearly l...

8 years ago | 0

| accepted

Answered
How can I have multiple authors for a File Exchange uploaded file
* create an account using a name that represents your group and you as the contact person, or * clearly write all of the author...

8 years ago | 1

Load more