Community Profile

# Chunru

Last seen: Today Active since 2013

Matlab user since 1990

All

#### Content Feed

View by

Hypothetical Factorial Question Solution
x = 120; nfact = 1; for i = 1:x nfact = nfact*i; if nfact==x fprintf("%d = %d!\n", x, i) break ...

etwa eine Stunde ago | 0

Invert even and odd columns in an image
a = randn(10, 10, 3); imshow(a) % swap even and odd columns b = zeros(size(a)); b(:, 1:2:end, :) = a(:, 2:2:end, :); b(:, 2...

etwa eine Stunde ago | 1

why I receive this error "Array indices must be positive integers or logical values"?
gamma = 0.5; beta = 0.9; w = 0.3; r = 1.2; [c1star] = c1a(w,r,gamma,beta) function c1a = c1a(w,r,gamma,beta) % ...

etwa 16 Stunden ago | 0

| accepted

Can I remove zeroth order baseline?
raw = readtable('raw.xlsx'); Xcontractions = raw.rXcont; Ycontractions = raw.rYcont; Time = raw.Time; %% Low-pass filter ...

etwa 22 Stunden ago | 0

| accepted

Multiple bar plot of different datasets in the same figure
x = rand(6,2); b = bar(x); % control the color of individual bar % 1st group first bar b(1).FaceColor = 'flat'; b(1).CDat...

ein Tag ago | 1

| accepted

FFT Amplitude and FFT Normalization
There are different ways of interpreting the FT. Here is one way according to Parseval's theorem: or The LHS of the firs...

ein Tag ago | 0

I need ziggurat matlab code to draw
where is a normalizing constant that we can ignore. x = [0:.1:2] y = 1/(2*pi)*exp(-x.^2/2); stairs(x, y, 'b'); hold o...

2 Tage ago | 0

Find the variation of x(t)
syms x(t) Dx = diff(x, t); eqn = diff(Dx, t) + 7* Dx + 5*x == 8 cond = [x(0)==1, Dx(0)==2]; y = dsolve(eqn, cond) fplot(y, ...

2 Tage ago | 0

| accepted

matlab solver with respect to x^2
syms x a y equ1=x^2+x^4==a equ2 = subs(equ1, x^2, y) S=solve(equ1,x) Sx2 =solve(equ2) subs(Sx2, a, 1)

6 Tage ago | 0

How to count the number of white pixels
First, you should use gray scale image. Second you have a large white margin in your data (which is not seen from imshow). You...

6 Tage ago | 1

| accepted

How to plug in algebraic equation and solution for it?
It seems that the equation you give has no soltion. f = @(t) 3.7 *( 1 + 4.1*.006/170*(3.7/180)^(2/3) * nthroot(t.^5, 3)).^-1.5;...

6 Tage ago | 0

removing some data in a 4d plot
data = load('4dplot.txt'); % x = 4dplot(:,1); % wrong: variable names canno start with number x = data(:,1);...

7 Tage ago | 1

How to convert a text file into a table properly
Try this: fid = fopen('test.txt', 'r'); fgetl(fid); % skip the header i=1; x = []; while ~feof(fid) s = fgetl(fid); ...

7 Tage ago | 0

What optimizer should I use?
Consider your objective function f(T, R1, R2), whose dependence on R2 lies on the first term only. To minimise f, R2 need to ...

7 Tage ago | 0

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

7 Tage ago | 0

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

8 Tage ago | 0

| accepted

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

8 Tage ago | 0

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

8 Tage ago | 0

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

8 Tage ago | 0

| accepted

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

8 Tage ago | 0

| accepted

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

8 Tage ago | 0

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

9 Tage ago | 0

| accepted

Create an array in workspace from multiple files
unzip("kx values.zip"); filenames = dir('*.txt'); filenames = sort({filenames.name}'); nfiles = length(filenames); nfiles = ...

10 Tage ago | 0

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

10 Tage ago | 0

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

10 Tage ago | 0

| accepted

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

10 Tage ago | 0

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

10 Tage ago | 0

| accepted

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

10 Tage ago | 1

| accepted