Answered
Randperm without the number 1
1+randperm(50-1)

6 years ago | 0

| accepted

Answered
MATLAB Faulty Logical Indexing?
"I suspect it is a potential bug" Nope. The cause is that you are testing for exact equality of binary floating point numbers. ...

6 years ago | 1

| accepted

Answered
Delete multiple elements from matrix, that match value at once
The simple MATLAB solution is to use ismember to generate the indices: >> A = [1,2,3,4,5;3,4,6,7,8;1,2,4,5,6;8,7,6,3,4;1,2,3,4,...

6 years ago | 0

| accepted

Answered
How to specify which version of a function to use?
The grpdelay documentation states "Frequencies, specified as a vector. fin must have at least two elements, because otherwise th...

6 years ago | 0

| accepted

Answered
Matlab Sort Command Output
Using separate variables makes this rather complex. It would be much simpler if you stored the data in arrays, e.g. in one tabl...

6 years ago | 1

Answered
How to extract data from cell array
Because you did not upload a sample file I created one (attached) based on your example data. str = fileread('trial.txt'); % re...

6 years ago | 0

| accepted

Answered
Automatic import of data and rename of array
Creating lots of dynamically named varaibles is not a good approach, and should be avoided. You should follow the examples in t...

6 years ago | 0

| accepted

Answered
Generating linear array [0 -1 0 1 -2 -1 0 1 2 ......]
N = 4; C = cell(1,N); for k = 1:N C{k} = -k:k; end V = [0,C{:}] Giving: V = 0 -1 0 1 -2 -1 0 1 2 -3...

6 years ago | 3

| accepted

Answered
How to find the indeces of same values within two vectors with repetitive values?
The example data from your question: >> A = [1000,2000,2000,5000,20000,20000]; >> B = [1000,2000,2000,5000,10000,20000,20000,6...

6 years ago | 1

| accepted

Answered
How to search for strings in strings?
>> str = '011_c_srr_Rtzfi_at000_hh5_fs_v343_l067_i1_Test_Test'; >> tmp = regexp(str,'(?<=_l)\d+','match','once'); >> num = str...

6 years ago | 0

Answered
What am i doing wrong? This expression is violating basic Mathematics.
Your code has two loops, loop j is nested inside loop i. You allocate data to pos1 only using index j, which means that you rep...

6 years ago | 0

| accepted

Answered
Splitting vectors into cell array in a loop
>> a = [1,3,5,7,9,10,8,6,4,3,2,3,5,6,9,10,7,5,3,2,1,3,4,6,8,9,10]; >> d = [false,diff(a)>0,false]; >> B = find(diff(d)>0); >>...

6 years ago | 0

| accepted

Answered
How do I use a variable (say "i", as in for i=1:10), as part of a variable name?
The MATLAB documentation recommends using a cell array (being much simpler and more efficient than what you are attempting to do...

6 years ago | 0

Answered
workaround for handling a large number of variables in the objective function of lsqnonlin
>> X = rand(7,3); >> w = rand(3,1); >> w(1)*X(:,1) + w(2)*X(:,2) + w(3)*X(:,3) % what you do now ans = 0.63892 0.4308...

6 years ago | 1

| accepted

Answered
how can i avoid the for loop in this case?
Method one: logical equals: >> a = [3,6,7,8]; >> V = 1:10; >> M = double(V(:)==a) % requires MATLAB >= R2016b M = 0 0 ...

6 years ago | 0

| accepted

Answered
How to combine the result of for loop?
>> A = 1:3; >> repelem(A,1,A) ans = 1 2 2 3 3 3

6 years ago | 0

| accepted

Answered
Dot indexing is not supported for variables of this type
You used the same name for two different variables: Change the name of the serial link variable to something else. You will n...

6 years ago | 0

| accepted

Answered
Function to format number as currency?
Just one simple Python call: num = 98765432.1; str = char(py.locale.currency(num, pyargs('grouping',py.True))) Or alternative...

6 years ago | 4

Answered
Using switch case to rename files in a folder
Method one: datetime scalar: Before the loop, define both the step size and the first time: >> step = minutes(10); >> first ...

6 years ago | 0

| accepted

Answered
plotting functions in matlab
function [y] = myfunction(theta) % "/" is not valid in a variable name y = sin(theta); end

6 years ago | 0

| accepted

Answered
i have a docuemnt with lots of numbers and i want to remove them for textanlaytics
str = fileread(...); str = regexprep(str,'\d+m?','');

6 years ago | 0

Answered
Index in position 1 exceeds array bounds (must not exceed 1818)
"What does "Index in position 1 exceeds array bounds" mean?" Here are the index positions for subscript indexing: anyarray(pos...

6 years ago | 0

Answered
Sometimes i sum the variable equal to 1. But when check the sum value, the logic is not correct. for example, P_SE = [0.5 0.2 0.2 0.1]. And, check sum(P_SE) == 1 but the logic shows 0. How can I fix this problem?
"...the logic is not correct..." The logic is correct: those values do NOT sum to exactly one. Neither of 0.1 nor 0.2 can be re...

6 years ago | 0

Answered
Sort variables form lowest to largest but by keeping their name
Using separate variables is an approach that will force you into writing slow, inefficient, complex code. A much better use of M...

6 years ago | 0

Answered
What exactly is this 3D object inside my axis and how to attach it to a colormap?
That figure contains four objects, the fourth one listed is the main axes: >> fgh = openfig('Resultplot_ID3.fig'); >> fgh.Chil...

6 years ago | 0

| accepted

Answered
What the difference between using bracket and not.
None of the answers explain why this works, nor even mentioned the useful-to-know name of this syntax. The actual reason is bec...

6 years ago | 5

| accepted

Answered
Create a 1 x m Structure instead of a 1x1 Structure
S = struct('FirstField',num2cell(1:100), 'SecondField',num2cell(1:100))

6 years ago | 2

| accepted

Answered
Function implementation in matlab
>> a = 0.9; >> V = 0:40; >> M = a.^(V+V(:)); % requires >=R2016b For earlier versions replace the + with bsxfun.

6 years ago | 0

Answered
How to find all the combinations of a vector elements whose sum is equal to a given number
A simple recursive nested function, with short-circuiting for combinations whose sums are greater than N (this makes the whole t...

6 years ago | 0

| accepted

Answered
Sum and Difference across row and column
>> sum(A(:,2))-A(2,1)-A(2,3) ans = -0.19880

6 years ago | 0

| accepted

Load more