Answered

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...

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...

10 dagen ago | 2

| accepted

Answered

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 ...

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 ...

10 dagen ago | 1

Answered

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(...

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(...

14 dagen ago | 0

| accepted

Answered

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)); ...

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)); ...

15 dagen ago | 0

Answered

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...

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...

15 dagen ago | 0

Answered

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} = ... ...

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} = ... ...

15 dagen ago | 0

| accepted

Answered

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...

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...

17 dagen ago | 2

Answered

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...

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...

17 dagen ago | 0

Answered

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...

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...

17 dagen ago | 0

| accepted

Answered

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...

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...

18 dagen ago | 0

| accepted

Answered

MATLAB DualCPU Hyper-Threading support

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

MATLAB DualCPU Hyper-Threading support

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

18 dagen ago | 0

| accepted

Answered

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(...

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(...

18 dagen ago | 0

Answered

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...

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...

18 dagen ago | 0

Answered

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;

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;

18 dagen ago | 0

| accepted

Answered

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".

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".

19 dagen ago | 0

Answered

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...

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...

21 dagen ago | 0

| accepted

Answered

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...

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...

21 dagen ago | 1

| accepted

Answered

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...

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...

21 dagen ago | 0

| accepted

Answered

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...

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...

21 dagen ago | 1

| accepted

Answered

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...

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...

22 dagen ago | 1

Answered

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 ...

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 ...

22 dagen ago | 1

| accepted

Answered

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';...

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';...

22 dagen ago | 0

| accepted

Answered

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, -...

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, -...

22 dagen ago | 1

| accepted

Answered

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...

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...

22 dagen ago | 0

| accepted

Answered

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: ...

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: ...

22 dagen ago | 0

Answered

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...

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...

23 dagen ago | 1

| accepted

Answered

incrementing over the alphabet???

count = 'a'; while 1 count = char(count + 1) end

incrementing over the alphabet???

count = 'a'; while 1 count = char(count + 1) end

23 dagen ago | 2

| accepted

Answered

Why am I getting a Duplicate directory name from the Applications folder in my MATLAB ?

Open pathdef.m and remove the duplicate folder.

Why am I getting a Duplicate directory name from the Applications folder in my MATLAB ?

Open pathdef.m and remove the duplicate folder.

23 dagen ago | 0

| accepted

Answered

¿how can I show a matrix of type -cell- in a msgbox?

Maybe this helps: https://www.mathworks.com/matlabcentral/fileexchange/9776-showcell-cell-disp

¿how can I show a matrix of type -cell- in a msgbox?

Maybe this helps: https://www.mathworks.com/matlabcentral/fileexchange/9776-showcell-cell-disp

23 dagen ago | 0

Answered

i need to make a matrix count a given set of repeated elements but it doesnt work at all

Maybe all you need is: [Lia, LocB] = ismember(points, coor, 'rows'); n = histcounts(LocB, 1:size(B, 1))

i need to make a matrix count a given set of repeated elements but it doesnt work at all

Maybe all you need is: [Lia, LocB] = ismember(points, coor, 'rows'); n = histcounts(LocB, 1:size(B, 1))

23 dagen ago | 0