Shuffle binary vector (n0 = n1) with constraints: number of consecutive repetitions
A brute force approach: function V = ShuffledVector x = 100; % Number of elements, assumed to be even Z = 5; V = [true(1, x...

8 dagen ago | 2

| accepted

how to calculate the area under a curve?
The area between a curve and the X axis is determined by the integral. So use trapz: x = 0:100; % Square brackets waste time ...

8 dagen ago | 1

Writing data to a structure array without loop
As written by Stephen before: There is no vectorized way to set the value of sub-fields of struct arrays. The expression [ax(...

12 dagen ago | 0

| accepted

How can I vectorize this function with nested FOR loop?
n = 1000; L = rand(24, n); T = zeros(n, 1); for i=1:n K = exp(-4*sum((L(:,i) - L) .^ 2, 1) ./ sum(L(:,i).^2, 1)); ...

13 dagen ago | 0

which matlab is compatible with windows 10, 64bit machine?
I'm running Matlab R2009a with the Signal Processing toolbox successfully under Windows 10. The installation and setup of the Me...

14 dagen ago | 0

Difficulty storing Output from Loop (Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 2-by-1)
To store arrays of different sizes, use a cell array: KMaxSBPFullTime = cell(1, 19); for i = 1:19 KMaxSBPFullTime{i} = ... ...

14 dagen ago | 0

| accepted

Which way of programming is more efficient and faster?
%Case 1 X = 1; Y = X + 4; Z = X + Y; %Case 2 X = 1; Y = X + 4; Z = X + Y; The documentation of Matlab stated, that the J...

15 dagen ago | 2

having problem to solve somthing in matlab
S = sum(x) is equivalent to S = 0; for k = 1:numel(x) S = S + x(k); end If you want to, you can call this as a subfunc...

15 dagen ago | 0

Nested loop problem with the second index
The problem of you code was cp(i.*j,:). i*j is not a growing index. In the 1st iteration 1*1 is fine. For i=1 it works for the c...

15 dagen ago | 0

| accepted

Can I overwrite a function in a compiled program with a custom version?
This will not work. And if it works, it would conflict with the license conditions. Do not provide parameters as M-functions, b...

16 dagen ago | 0

| accepted

Yes. Matlab will use the available cores. At least most likely. Matlab might split the array columnwise and if the input has 5 c...

16 dagen ago | 0

| accepted

Can anyone help me to understand the logic of below code
Start with a simplification of the code to make it easier to read: % find the points in the front surface for z = min(Zb):max(...

16 dagen ago | 0

Text files for export the data
Storing numerical data in text files has the disadvantage, that the values need to be converted twice. Prefer storing the data i...

16 dagen ago | 0

how to change the bit of any matrix?
A = [12, 23, 32, 14]; B = bitset(A, 4, 0) Or: S = de2bi(A); S(:, 4) = 0;

16 dagen ago | 0

| accepted

how can i stop my scripts opening in another window in R2019a?
There is a small circle with a triangle on the top right of the editor window. Open this popup menu and select "Dock Editor".

17 dagen ago | 0

Unable to perform assignment
If the initial condition has 3 elements: yo = [0.5;0.5;1], te evaluated trajectory will have 3 elements per time step also. Then...

19 dagen ago | 0

| accepted

Divide the shuffled sequence Q={Q1，Q2，Q3，···，Qm×n}. into MN/16 matrices which are 4×4. M=256 and N=256
Replace A=sort(x); [A,T]=sort(x); Q=R(T); by Q = Q(randperm(65536, 65536)); Then: Q4 = reshape(Q, 4, 4, numel(Q)/16) Now...

19 dagen ago | 1

| accepted

Why is my assigned variable not being detected/read?
Your code creates app.UserData, but the error message tells you, that the output UserData is not created: function UserData = R...

19 dagen ago | 0

| accepted

How does matlab handle removing elements memory wise?
You can use format debug to display the pointer to the memory (I cannot test this currently but hope, that this valuable tool is...

19 dagen ago | 1

| accepted

How to find the transformation matrix for a plat knowing the old and new coordinates of 3 points on it ?
You can define the motion by a translation of the center of the 3 points and a rotation of the local coordinate system. PointsA...

20 dagen ago | 1

How not to repeat the whole code after the try catch loop ?
A bold guess, which contains at least the terms "loop" and "try catch" and "avoid rewriting it": ready = false; while ~ready ...

20 dagen ago | 1

| accepted

Split cell array rows by delimiter (2016b)
Let's start with a loop approach to clarify at first, what you exactly want: C = {'LINE1'; ... '* THIS IS A COMMENT LINE';...

20 dagen ago | 0

| accepted

How to determine whether point lies within pyramid volume
Because the pyramid is regular, the algorithm is easy: E0 = [ 0, 0, 1]; E1 = [ 1, 1, 0]; E2 = [-1, 1, 0]; E3 = [-1, -...

20 dagen ago | 1

| accepted

Running a script from a Linux terminal using "matlab -r"
The error message means, that you try to create a folder inside a path, in which you do not have write access. The solution is e...

20 dagen ago | 0

| accepted

How can I check in an arbitrary vector that the first index is greater than the next index and so on?
BR = [15 2 1 12 8 5 6 11 4 9 10 7 3 14 13] Now you want to determine, if an element is larger or smaller than the former one: ...

21 dagen ago | 0

i want to export two "100X1 double" matrix into one tab delimited .txt file. file should have two columns with tab delimiter. column one with matrix one and column two with matrix two data.
Omit the transposing. Then: data = [inPhaseOsc; quadPhaseOsc]; [fid, msg] = fopen(FileName, 'w'); assert(fid > 0, 'Cannot ope...

21 dagen ago | 1

| accepted

incrementing over the alphabet???
count = 'a'; while 1 count = char(count + 1) end

21 dagen ago | 2

| accepted

Why am I getting a Duplicate directory name from the Applications folder in my MATLAB ?
Open pathdef.m and remove the duplicate folder.

21 dagen ago | 0

| accepted