Answered

How to convert a text file into a table properly

T = readtable('test.txt', 'Delimiter', '-->') for i=1:size(T,1) for j=2:size(T,2) T{i, j}{1} = str2num(T{i, j}{1}...

How to convert a text file into a table properly

T = readtable('test.txt', 'Delimiter', '-->') for i=1:size(T,1) for j=2:size(T,2) T{i, j}{1} = str2num(T{i, j}{1}...

17 days ago | 0

Answered

ga optimization changing answer

GA need random initialization of population and it also involves random processing in generating children. Therefore, the resul...

ga optimization changing answer

GA need random initialization of population and it also involves random processing in generating children. Therefore, the resul...

17 days ago | 0

| accepted

Answered

How to make a Comparison of the values of a matrix for different iteration ?

A=randi([2 5],[3,4]) j=10 for i=1:j B=A.*randi([2 5] ,[3,4]); % Do your comparison here between B and A %...

How to make a Comparison of the values of a matrix for different iteration ?

A=randi([2 5],[3,4]) j=10 for i=1:j B=A.*randi([2 5] ,[3,4]); % Do your comparison here between B and A %...

17 days ago | 0

Answered

Calculate peak of pulses above certain threshold

load example.mat %whos plot(C(19e5:20e5)); % compute envelope before findpeaks env = envelope(C, 1000, 'peak'); hold on ...

Calculate peak of pulses above certain threshold

load example.mat %whos plot(C(19e5:20e5)); % compute envelope before findpeaks env = envelope(C, 1000, 'peak'); hold on ...

17 days ago | 0

Answered

Dividing matrices of different dimensions

B = reshape(1:64, 8, 8); % generate B matrix A = repmat(B, [32 32]); % repeating 32x32 imagesc(A)

Dividing matrices of different dimensions

B = reshape(1:64, 8, 8); % generate B matrix A = repmat(B, [32 32]); % repeating 32x32 imagesc(A)

18 days ago | 0

| accepted

Answered

How do you plot the average of a group of lines in a figure?

h = openfig("Damping_mode_2.fig", "visible"); hl = findobj(h, 'Type', 'Legend'); hl.Location = 'southoutside'; hl.NumColumns =...

How do you plot the average of a group of lines in a figure?

h = openfig("Damping_mode_2.fig", "visible"); hl = findobj(h, 'Type', 'Legend'); hl.Location = 'southoutside'; hl.NumColumns =...

18 days ago | 0

| accepted

Answered

How to generate 3D surface from 2D graph

a = (0:0.1:2.4)'; theta = 0:360; c= sqrt(a.^2+4); p = 23e-7./(c.^6); pp = repmat(p', [length(theta) 1]); [aa, tt] =...

How to generate 3D surface from 2D graph

a = (0:0.1:2.4)'; theta = 0:360; c= sqrt(a.^2+4); p = 23e-7./(c.^6); pp = repmat(p', [length(theta) 1]); [aa, tt] =...

18 days ago | 0

Answered

Asign subjects to groups and get a group average

% 3 Variables - Subject ID (N = 1026) , Group ID (Total of 457 groups) and IQ score (one for each subject). N = 1026; id = ran...

Asign subjects to groups and get a group average

% 3 Variables - Subject ID (N = 1026) , Group ID (Total of 457 groups) and IQ score (one for each subject). N = 1026; id = ran...

18 days ago | 0

| accepted

Answered

Create an array in workspace from multiple files

unzip("kx values.zip"); filenames = dir('*.txt'); filenames = sort({filenames.name}'); nfiles = length(filenames); nfiles = ...

Create an array in workspace from multiple files

unzip("kx values.zip"); filenames = dir('*.txt'); filenames = sort({filenames.name}'); nfiles = length(filenames); nfiles = ...

19 days ago | 0

Answered

How to plot multiple plots

theta_all = [0.1095, 0.1075, 0.1075, 0.1055]; for theta=theta_all YF=0.0667; alpha= 0.29; beta= 0.68; gamm...

How to plot multiple plots

theta_all = [0.1095, 0.1075, 0.1075, 0.1055]; for theta=theta_all YF=0.0667; alpha= 0.29; beta= 0.68; gamm...

19 days ago | 0

Answered

Intergrating from negative infinity to infinity

The following correct the syntax error in your original program. You need to check/debug the function definition to ensure it i...

Intergrating from negative infinity to infinity

The following correct the syntax error in your original program. You need to check/debug the function definition to ensure it i...

19 days ago | 0

| accepted

Answered

How to find first negative solution with the bisection method

g = @(x) x + 1 -2 * sin(pi*x) ; % Use interval [-1.5, 0] for example [c, n, err] = Bisection_method(g, -1.5, 0, 1e-6, 1000) ...

How to find first negative solution with the bisection method

g = @(x) x + 1 -2 * sin(pi*x) ; % Use interval [-1.5, 0] for example [c, n, err] = Bisection_method(g, -1.5, 0, 1e-6, 1000) ...

20 days ago | 0

Answered

Create a right axis which correspond to the first axis.

freq = [1000:10:5000]; wn = [-1.5:0.01:1.5]; p = 1./freq; h1= axes; data = randn(length(freq), length(wn)); imagesc(wn, f...

Create a right axis which correspond to the first axis.

freq = [1000:10:5000]; wn = [-1.5:0.01:1.5]; p = 1./freq; h1= axes; data = randn(length(freq), length(wn)); imagesc(wn, f...

20 days ago | 0

| accepted

Answered

How to name files in a folder based on parent folder?

for i=1:6 % 6 folders foldername = sprintf('simulation_data%d', i) mkdir(foldername) cd(foldername) ...

How to name files in a folder based on parent folder?

for i=1:6 % 6 folders foldername = sprintf('simulation_data%d', i) mkdir(foldername) cd(foldername) ...

20 days ago | 1

| accepted

Answered

Cut off frequency doesn't works.

Fs=200e3; Ts=1/Fs; t=0:Ts:(5e-3-Ts); y=5*sin(2*pi*1000*t)+5*sin(2*pi*20000*t)+10*sin(2*pi*30000*t); nfft=length(y); nfft2...

Cut off frequency doesn't works.

Fs=200e3; Ts=1/Fs; t=0:Ts:(5e-3-Ts); y=5*sin(2*pi*1000*t)+5*sin(2*pi*20000*t)+10*sin(2*pi*30000*t); nfft=length(y); nfft2...

23 days ago | 0

Answered

Plot the graph using non linear equation

It seems that you are solve equations of h for different parameters theta. You can solve the equation one by one. Don't add sp...

Plot the graph using non linear equation

It seems that you are solve equations of h for different parameters theta. You can solve the equation one by one. Don't add sp...

23 days ago | 0

| accepted

Answered

Runga-Kutta Method for system of first order differential equations

Looks like you need to choose a much smaller step size for the problem. %% Initialization tspan = 100; h = 0.125/50; fact = ...

Runga-Kutta Method for system of first order differential equations

Looks like you need to choose a much smaller step size for the problem. %% Initialization tspan = 100; h = 0.125/50; fact = ...

23 days ago | 0

Answered

Extract data above threshold from groups

load('xydata.mat') edges = (min(pp):20:max(pp)); [N, edges, bin] = histcounts(pp, edges); figure gscatter(pp,cc,bin) ...

Extract data above threshold from groups

load('xydata.mat') edges = (min(pp):20:max(pp)); [N, edges, bin] = histcounts(pp, edges); figure gscatter(pp,cc,bin) ...

24 days ago | 0

| accepted

Answered

subplot with for loop after 10 new figure

for i=1:100 % any number if rem(i-1, 10) == 0 figure; end sgtitle('WSPL zeitlicher Verlauf Modell D Te...

subplot with for loop after 10 new figure

for i=1:100 % any number if rem(i-1, 10) == 0 figure; end sgtitle('WSPL zeitlicher Verlauf Modell D Te...

24 days ago | 0

| accepted

Answered

How to check if my array is square with if and else loops?

A = [1 -2 1; 0 2 -8; -4 5 9] if ndims(A)==2 && (size(A,1)==size(A,2)) disp("A is Square") end

How to check if my array is square with if and else loops?

A = [1 -2 1; 0 2 -8; -4 5 9] if ndims(A)==2 && (size(A,1)==size(A,2)) disp("A is Square") end

24 days ago | 0

| accepted

Answered

Showing legend even if data is not there

a=(1:1:9)'; a=reshape(a,3,[]); b=sin(a); c=cos(a); scatter(a,b,'.','DisplayName', 'sin') hold on scatter(a,c,'.','Displa...

Showing legend even if data is not there

a=(1:1:9)'; a=reshape(a,3,[]); b=sin(a); c=cos(a); scatter(a,b,'.','DisplayName', 'sin') hold on scatter(a,c,'.','Displa...

24 days ago | 0

| accepted

Answered

Cell in table data type conversion

a = (1:3)'; b = {'yes', 'no', 'yes'}'; t = table(a,b) t.b = categorical(t.b)=='yes'

Cell in table data type conversion

a = (1:3)'; b = {'yes', 'no', 'yes'}'; t = table(a,b) t.b = categorical(t.b)=='yes'

24 days ago | 0

| accepted

Answered

How can I create a new matrix which stores the diagonals, but it first starts with a matrix full of zeros?

% start with zero matrix n=3; a = zeros(3) % random entries along diagonal a(1:n+1:n*n) = randi(100, [n 1]) % alternative...

How can I create a new matrix which stores the diagonals, but it first starts with a matrix full of zeros?

% start with zero matrix n=3; a = zeros(3) % random entries along diagonal a(1:n+1:n*n) = randi(100, [n 1]) % alternative...

24 days ago | 0

| accepted

Answered

Which is my mistake?

N = 60; n = 0:N-1; b = [0.18 0.1 0.3 0.1 0.18]; a = [1 -1.15 1.5 -0.7 0.25]; %d = delta(n(19n), 0 , n(end)); d = zeros(size...

Which is my mistake?

N = 60; n = 0:N-1; b = [0.18 0.1 0.3 0.1 0.18]; a = [1 -1.15 1.5 -0.7 0.25]; %d = delta(n(19n), 0 , n(end)); d = zeros(size...

30 days ago | 0

| accepted

Answered

How can I display text on pcolor map like in the image below?

L = membrane(1, 100); s=pcolor(L); s.EdgeColor='none'; set(gca, 'YDir', 'reverse') xl = xlim; yl = ylim; n = 1; xy =[]; ...

How can I display text on pcolor map like in the image below?

L = membrane(1, 100); s=pcolor(L); s.EdgeColor='none'; set(gca, 'YDir', 'reverse') xl = xlim; yl = ylim; n = 1; xy =[]; ...

1 month ago | 0

| accepted

Answered

How to change the values of the corners in a matrix

a= zeros(10, 10); % smaller matrix for easy display % for corners a([1 end], [1 end]) = 1; a

How to change the values of the corners in a matrix

a= zeros(10, 10); % smaller matrix for easy display % for corners a([1 end], [1 end]) = 1; a

1 month ago | 0

| accepted

Answered

Why does my code slow down around the 20th iteration?

The recursive function is the culprit of the speed. Simply replace them with mean and var. A_set = []; n=1; while 1==1 %eval...

Why does my code slow down around the 20th iteration?

The recursive function is the culprit of the speed. Simply replace them with mean and var. A_set = []; n=1; while 1==1 %eval...

1 month ago | 0

| accepted

Answered

Plotting with bisection method

Bisection method tries to find solution in a given interval. Generally, you don't know how many roots a non-linear equation has...

Plotting with bisection method

Bisection method tries to find solution in a given interval. Generally, you don't know how many roots a non-linear equation has...

1 month ago | 0

| accepted

Answered

Name table columns with variable index

tab = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/980210/MATWORKS.csv'); head(tab) varnames = ta...

Name table columns with variable index

tab = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/980210/MATWORKS.csv'); head(tab) varnames = ta...

1 month ago | 0

| accepted

Answered

How to save results in a file without overwritting previous results????

Use append option when you save the data to files. [You can also use low-level fopen with option 'a+' for appending] % create ...

How to save results in a file without overwritting previous results????

Use append option when you save the data to files. [You can also use low-level fopen with option 'a+' for appending] % create ...

1 month ago | 0