Risposto
Matlab file names in a loop
fn = dir("dipoles*.*"); for i = 1:length(fn) x{i} = readmatrix(fn(i).name, "NumHeaderLines", 27); end x

circa 2 anni fa | 0

Risposto
Is this correct?
x=-15:15; y = zeros(size(x)); % This is more MATLAB way idx = x<0; y(idx) = 5 * x(idx); idx = x>=0 & x<2; y(idx...

circa 2 anni fa | 0

| accettato

Risposto
Determine time lag from xcorr?
circshift with a positive shift number is to delay the signal A to form B. Now exeamine the defination of xcorr in MATLAB: R...

circa 2 anni fa | 0

Risposto
Determine time lag from xcorr?
doc xcorr for details. [r,lags] = xcorr(___) % Find the peak or r [pk, idx] = max(r); % for example lags(idx)/fs ...

circa 2 anni fa | 0

Domanda


Live function with optional arguments: doc has strange behavior
I am creating live function with optional argument. Below is an example. When we use the command doc optionalArgs to genera...

circa 2 anni fa | 0 risposte | 0

0

risposte

Domanda


[ ] or ( ) in constructing array
In constructing array, we can have different styles as show below. Personally, I found that using [ ] is a better choice in MAT...

circa 2 anni fa | 4 risposte | 2

4

risposte

Risposto
Selecting specific rows and then summing them up
A=[1:12555]; B = A(10:10:end); % choose 10,20,30,... mean(B)

circa 2 anni fa | 0

| accettato

Risposto
integral() not working properly?
% This is an oscillating function. It is difficult for numerical % integration to converge (automatically compute intervals). ...

circa 2 anni fa | 1

Risposto
Delete Array Element Based on Conditions
load Coordinates.mat z_ref = [411.2966 426.2966 441.2966 456.2966 471.2966 486.2966 501.2966 545 575 605 635 665 695]; for i =...

circa 2 anni fa | 1

| accettato

Risposto
How to find the row and column of the largest number in an array?
A = [4.4347 4.5156; 4.462 4.7074;1.111 .985 ] [Amax, idx] = max(A(:)) [i, j] = ind2sub(size(A), idx)

circa 2 anni fa | 0

| accettato

Risposto
Error using vertcat Dimensions of arrays being concatenated are not consistent.
% some_var = ['AB'; 'CD', 'EF'] % semicolon for new rows and comma for new coloumn. so the above is wrong % The code be...

circa 2 anni fa | 0

| accettato

Risposto
solving a triple sigma equation (or triple integral)
% for A = 6 x 61 x 17 (3-d array) A = ones(6,61,17); k = linspace(10.4, 31.4, 6); pii = linspace(0, pi, 61); % p...

circa 2 anni fa | 0

| accettato

Risposto
creating folder in matlab
% create folder (in current folder) folder = "mydir"; mkdir(folder); % save data in a file in the folder a = rand(3); sav...

circa 2 anni fa | 0

Risposto
Plot values of a boxplot next to it?
x1 = rand(5,1); x2 = rand(10,1); x3 = rand(15,1); x = [x1; x2; x3]; g1 = repmat({'First'},5,1); g2 = repmat({'Second'},10...

circa 2 anni fa | 0

| accettato

Risposto
How to filter out rows from a very long table
a = [ 21613 864.52 25 114.0714 -25.8369 21614 864.56 26 114.1197 -26.0363 21615 864.6 27 114.1688 -26.2351 21616 864.64 ...

circa 2 anni fa | 0

| accettato

Risposto
Extract the data in a certain range
% assume that your data is x t1 = 0.9470; t2=1.4240; x_extracted = x(x.Time>=t1 & x.Time<=t2, :)

circa 2 anni fa | 0

| accettato

Risposto
Large amount of coordinates transformation in 3D
Transpose A: theta = 10; A = [0 0 0; 1 1 1; 0 0 1; 1 1 0; 1 0 1; 0 1 0; 0 1 1; 1 0 0]'; x = A(:,1); y = A(:,2); z = A(:,3)...

circa 2 anni fa | 0

| accettato

Risposto
How to plot it?
a = [1,2,3,4,5]; b = [-1000,10,0,20,-20]; idx = b>=0; plot(a(idx), b(idx), 'o-');

circa 2 anni fa | 1

| accettato

Risposto
Vertical concatenation of cell array of different dimensions
% I am having two cell array of different dimensions, like a = 1*28 and b= 1*30. % I need to concatenate vertically and in the...

circa 2 anni fa | 0

Risposto
How to determine eigenvalues and eigenvectors?
% doc eig for more details A=[3,9;3,5] B=[2,0;0,8] [vA, dA] = eig(A) [vB, dB] = eig(B)

circa 2 anni fa | 0

Risposto
How to put different seed in a multidimensional matrix
Not sure why you have to do this. But it can be done as follows: n = 10; k=3; X = zeros([n,k,n]); seeds = [1:n]; % your se...

circa 2 anni fa | 0

Risposto
How can I extract string data from a tab delimited text file that I have pulled in as a structure (1x1)?
fn = "https://www.mathworks.com/matlabcentral/answers/uploaded_files/1063445/sample_file.csv"; % Read the file as strings l ...

circa 2 anni fa | 0

Risposto
Convert gregorian day to yyyy-mm
load Time.mat %time dt = datetime("1950-01-01 00:00:00") + days(time)

circa 2 anni fa | 1

| accettato

Risposto
How can I concatenate a string array of a dimension 1x N into one cell
% using cell array of char A = {'ABC', 'DEF', 'HIJK'} B = join(A, '/') % using string C = string(A) C = join(C, '/')

circa 2 anni fa | 0

| accettato

Risposto
Evaluation and plotting a kernel function
%Kernal 1 Fs = 33600 n = 1:1:33600; a = floor(n-(Fs/2)); c = (1200*pi)/Fs; % c is greek letter chi g = pi/Fs; ...

circa 2 anni fa | 0

Risposto
Polar plot for time representation
t = 0:(60*24*365); % time in min x = 1.5 + sin(2*pi*t/1000); % data polarplot(t/(60*24)*2*pi, x); % 1 day for 2pi radi...

circa 2 anni fa | 0

Risposto
How can I solve this coupled non-linear differential equation and graph it?
% initial condition cannot be [0, 0] since when rho0=0, you cannot define % d omega / d theta. [theta, y] = ode45(@myODE, [0...

circa 2 anni fa | 1

Risposto
How to find the derivative of one output quantity with respect to another output quantity
x = 0:32; y = sin(2*pi*x/16); d = gradient(y)./gradient(x); plot(x, y, 'r-', x, d, 'b-')

circa 2 anni fa | 0

Risposto
How does matlab go about drawing an image like the one below?
% x y ux1 uy1 ux2 uy2 data = [1 2 0.1 -0.3 1 1; 5 3 1 2 -1 -1 2 5...

circa 2 anni fa | 0

| accettato

Risposto
Plotting complex function N vs frequency for a range of values of N from 1 to 10
x = 1:0.5:10; for i = 1:length(x) N = x(i) fm(i) = sqrt(((8*Wm)*(asin(Cphi)^2)*(1+sqrt(1-(Cphi)^2)))/(rhom*(4*phimax*...

circa 2 anni fa | 1

| accettato

Carica altro