Answered

Sparse Matrix with Same number of non-zero values in each column

A = createMatrix(8, 4); full(A) function A = createMatrix(n, k) A = sparse(n,n); for i=1:n A(randperm(n, k), i) = 1/k; ...

Sparse Matrix with Same number of non-zero values in each column

A = createMatrix(8, 4); full(A) function A = createMatrix(n, k) A = sparse(n,n); for i=1:n A(randperm(n, k), i) = 1/k; ...

13 Tage ago | 0

| accepted

Answered

Displaying frames captured by getframe(h) at original size

You can use "imshow" which by default show images in 100% magnification. "doc imshow" for more details.

Displaying frames captured by getframe(h) at original size

You can use "imshow" which by default show images in 100% magnification. "doc imshow" for more details.

15 Tage ago | 0

| accepted

Answered

using imagesc to plot a matrix of data

%C = 0.1:0.1:0.2; C = [0.1 0.2]; % There are only two points along x F = 0.1:0.1:0.5; figure(1) subplot(1,3,1) mean_GT...

using imagesc to plot a matrix of data

%C = 0.1:0.1:0.2; C = [0.1 0.2]; % There are only two points along x F = 0.1:0.1:0.5; figure(1) subplot(1,3,1) mean_GT...

15 Tage ago | 0

| accepted

Answered

How to create a circle filled with equidistant points inside it?

Here is a sub-optimal (or almost optimal) solution. Filled dots will form the hexagonal formation. radius = 10; d = 1; % dis...

How to create a circle filled with equidistant points inside it?

Here is a sub-optimal (or almost optimal) solution. Filled dots will form the hexagonal formation. radius = 10; d = 1; % dis...

15 Tage ago | 0

| accepted

Answered

How I plot a matrix wich each rows is a different curves on the graph?

a = randn(6, 21); plot(a')

How I plot a matrix wich each rows is a different curves on the graph?

a = randn(6, 21); plot(a')

16 Tage ago | 0

| accepted

Answered

How to Convert Magnitude(g/N)/Phase (degrees) data in to Complex Receptance (m/N)

x =[0.00000e+000 1.16597e+002 -1.80000e+002 3.12500e-001 9.33462e+001 5.02240e+001 6.25000e-001 ...

How to Convert Magnitude(g/N)/Phase (degrees) data in to Complex Receptance (m/N)

x =[0.00000e+000 1.16597e+002 -1.80000e+002 3.12500e-001 9.33462e+001 5.02240e+001 6.25000e-001 ...

17 Tage ago | 0

Answered

3D Plot of a Matrix with only Char data type

x= {'USA', 'Germany', 'South Africa', 'China', 'Mexico', 'Australia'}; y = {'America', 'Europe', 'Africa', 'Asia', 'South Amer...

3D Plot of a Matrix with only Char data type

x= {'USA', 'Germany', 'South Africa', 'China', 'Mexico', 'Australia'}; y = {'America', 'Europe', 'Africa', 'Asia', 'South Amer...

17 Tage ago | 0

Answered

Massive time required for pdist

%tic X = rand(1000,2); Y = rand(1000,2); % fprintf('Time for array creation: '); %toc %% Version 1 tic j=1; for i = ...

Massive time required for pdist

%tic X = rand(1000,2); Y = rand(1000,2); % fprintf('Time for array creation: '); %toc %% Version 1 tic j=1; for i = ...

18 Tage ago | 0

| accepted

Answered

How to arrange the constraints shape to A matrix and b constants automatically ( Ax <= b)??

% Let x = [x1; x2; x3; x4] % x1 + x2 <= x3 + x4 + 1 ; % constraint 1 % => [1 1 -1 -1]*x <= 1 % X3 <= x1 + 10 ; % cons...

How to arrange the constraints shape to A matrix and b constants automatically ( Ax <= b)??

% Let x = [x1; x2; x3; x4] % x1 + x2 <= x3 + x4 + 1 ; % constraint 1 % => [1 1 -1 -1]*x <= 1 % X3 <= x1 + 10 ; % cons...

20 Tage ago | 0

Answered

Array of Structures to Structure of arrays

% array of structure M = 5; for i=1:M a(i).f1 = rand(1,1); a(i).f2 = rand(1,1); end a a(1) % struncrure of arr...

Array of Structures to Structure of arrays

% array of structure M = 5; for i=1:M a(i).f1 = rand(1,1); a(i).f2 = rand(1,1); end a a(1) % struncrure of arr...

21 Tage ago | 0

Answered

How to detect and delete similar value rows in Matlab?

A =[1 2 3 4; 1 3 4 2; 1 4 2 4; 1 3 2 2]; % For columns with the same values i = find(all(diff(A, 1)==0, 1)); ...

How to detect and delete similar value rows in Matlab?

A =[1 2 3 4; 1 3 4 2; 1 4 2 4; 1 3 2 2]; % For columns with the same values i = find(all(diff(A, 1)==0, 1)); ...

23 Tage ago | 0

Answered

How to collect output matrix from for loop

If you want to accumate over different matrices n = 10; A = zeros(3, 3) for i=1:n A = A + randi(5,3,3); end A If you ...

How to collect output matrix from for loop

If you want to accumate over different matrices n = 10; A = zeros(3, 3) for i=1:n A = A + randi(5,3,3); end A If you ...

23 Tage ago | 0

| accepted

Answered

Write a script file that will compute the sine of an angle using the Taylor series formula:

disp("Input the angle in degrees (x) and the number of terms (n)") %x = input('x: '); x = 45; %n = input('n: '); n = 100; ...

Write a script file that will compute the sine of an angle using the Taylor series formula:

disp("Input the angle in degrees (x) and the number of terms (n)") %x = input('x: '); x = 45; %n = input('n: '); n = 100; ...

23 Tage ago | 0

Answered

how to normalize a uniformly distributed random values such that every row sum of X(:,:,i) should be 1 except for ith row?

n=6; key_size=3; i=5; X = rand([n,key_size,6]); idx = [1:i-1 i+1:n]; X (idx, :, :) = X (idx, :, :)./sum(X (idx, :, :), 2); ...

how to normalize a uniformly distributed random values such that every row sum of X(:,:,i) should be 1 except for ith row?

n=6; key_size=3; i=5; X = rand([n,key_size,6]); idx = [1:i-1 i+1:n]; X (idx, :, :) = X (idx, :, :)./sum(X (idx, :, :), 2); ...

23 Tage ago | 0

Answered

Please Help Debug/ What are the errors?

t=-2:0.1:8; % define t first, since it is used next y=t.^3-6*t.^2+3*t+10; % need the element based operat...

Please Help Debug/ What are the errors?

t=-2:0.1:8; % define t first, since it is used next y=t.^3-6*t.^2+3*t+10; % need the element based operat...

23 Tage ago | 0

Answered

Count occurrences of categorical conjunction

Cat_one = categorical({'A'; 'B'; 'A'; 'D'; 'C'; 'B'; 'B'; 'A'; 'A'}); Cat_two = categorical({'X'; 'X'; 'Y'; 'Y'; 'Y'; 'X'; 'Y';...

Count occurrences of categorical conjunction

Cat_one = categorical({'A'; 'B'; 'A'; 'D'; 'C'; 'B'; 'B'; 'A'; 'A'}); Cat_two = categorical({'X'; 'X'; 'Y'; 'Y'; 'Y'; 'X'; 'Y';...

24 Tage ago | 1

| accepted

Answered

How to plot array with result of roots?

P=1:0.1:10; A=P; B=-(10+5*P); % 5*P not 5P C=3; D=-15; for i =1 : length(P) fv=[A(i) B(i) C D] v(i)=max(roots...

How to plot array with result of roots?

P=1:0.1:10; A=P; B=-(10+5*P); % 5*P not 5P C=3; D=-15; for i =1 : length(P) fv=[A(i) B(i) C D] v(i)=max(roots...

24 Tage ago | 0

| accepted

Answered

What am I missing with plot? math is working fine, just need to plot it.

For ervery loop, you have only one point (x,y) which you can not plot as a line. Use plot(x, y, 'bo') to plot the point instead...

What am I missing with plot? math is working fine, just need to plot it.

For ervery loop, you have only one point (x,y) which you can not plot as a line. Use plot(x, y, 'bo') to plot the point instead...

24 Tage ago | 0

| accepted

Answered

sampling and FFT of a sinusoid signal

f0 = 50; fs = 250; t = (0:1/fs:(0.1-.5/fs)); % [0, 0.1) g = sin(2*pi*f0*t); plot(t, g); L = 512 Y = fft(g, L); % compute...

sampling and FFT of a sinusoid signal

f0 = 50; fs = 250; t = (0:1/fs:(0.1-.5/fs)); % [0, 0.1) g = sin(2*pi*f0*t); plot(t, g); L = 512 Y = fft(g, L); % compute...

25 Tage ago | 0

| accepted

Answered

Why the following code does not give me the 3D plot. Please someone help me out.

In your definition of R0, there is a term rho1+rho2, which happen to be 0. So R0 is just 0. Check your formula first.

Why the following code does not give me the 3D plot. Please someone help me out.

In your definition of R0, there is a term rho1+rho2, which happen to be 0. So R0 is just 0. Check your formula first.

26 Tage ago | 0

Answered

How to find standard deviation of all entries in a range and omit nan

A=rand(10); StdssA=std(A(2:4,3:7), 0, 'all', 'omitnan') % doc std

How to find standard deviation of all entries in a range and omit nan

A=rand(10); StdssA=std(A(2:4,3:7), 0, 'all', 'omitnan') % doc std

26 Tage ago | 0

Answered

How to reduce computation time with 8 nested for loop

Brute force searching for such problem is not feasible. If it takes around 10 days to reach to 10^13, it takes 10*10^11=10^12 d...

How to reduce computation time with 8 nested for loop

Brute force searching for such problem is not feasible. If it takes around 10 days to reach to 10^13, it takes 10*10^11=10^12 d...

27 Tage ago | 0

Answered

Display value of a variable within ' '

system([stata_location ' -b do mydir/mydofile ' num2str(run_id)]);

Display value of a variable within ' '

system([stata_location ' -b do mydir/mydofile ' num2str(run_id)]);

27 Tage ago | 0

Answered

why is this happening? It's just an example from the textbook.

syms x f=@(x) x-3; r=solve(f, x)

why is this happening? It's just an example from the textbook.

syms x f=@(x) x-3; r=solve(f, x)

28 Tage ago | 0

Answered

How to computer a frequency spectrum and find its largest spectral energy

fs = 10; tspan = [0:1/fs:100]; % specify the time points xint = [3.0;2.0;1.0]; [t,x]= ode45(@nonlin,tspan,xint); % remov...

How to computer a frequency spectrum and find its largest spectral energy

fs = 10; tspan = [0:1/fs:100]; % specify the time points xint = [3.0;2.0;1.0]; [t,x]= ode45(@nonlin,tspan,xint); % remov...

28 Tage ago | 0

Answered

How to delete specific cells according to the condition from cell array?

If you want to keep the output as a cell array (as the input), you cannot delete them, but you can assign them to empty array. ...

How to delete specific cells according to the condition from cell array?

If you want to keep the output as a cell array (as the input), you cannot delete them, but you can assign them to empty array. ...

28 Tage ago | 1

Answered

Finding the required number of high frequency values from histogram

a = [randn(10000,1)-5; randn(10000,1); randn(10000,1)+5]; histogram(a) [y,edges] = histcounts(a); % Use the center of edges...

Finding the required number of high frequency values from histogram

a = [randn(10000,1)-5; randn(10000,1); randn(10000,1)+5]; histogram(a) [y,edges] = histcounts(a); % Use the center of edges...

29 Tage ago | 1

| accepted

Answered

How to find out roll-off from magnitude response of filter in matlab

fs = 2000; [b,a] = butter(9,400/(fs/2)); [h, f] = freqz(b,a,16384,fs); h = 20*log10(abs(h)); [~, i3db] = min(abs(h - 10*log1...

How to find out roll-off from magnitude response of filter in matlab

fs = 2000; [b,a] = butter(9,400/(fs/2)); [h, f] = freqz(b,a,16384,fs); h = 20*log10(abs(h)); [~, i3db] = min(abs(h - 10*log1...

29 Tage ago | 0

Answered

Finding location of specific element from a MATRIX returns '0×1 empty double column vector'

[i,j] = find(abs(a-23.5975)<1e-20)

Finding location of specific element from a MATRIX returns '0×1 empty double column vector'

[i,j] = find(abs(a-23.5975)<1e-20)

29 Tage ago | 0

| accepted