Risposto
I need to create a vector of indices for x and y coordinates and save with assigned value
x = [1.22, 2.33, 4.56]; y = [5.6, 7.3, 8.2]; for i=1:length(x) points(i).x = x(i); points(i).y = y(i); end point...

quasi 3 anni fa | 1

Risposto
Determine the number of "for" loops by the user
% The number of iterations ni = [3 4 2 2]; % 4 iterations [I J K R]; i is innerest loop idx = ones(size(ni)); % fir...

quasi 3 anni fa | 1

| accettato

Risposto
How can I find positive feedback loops from a directed graph?
s = [1 4 2 5 2 3 4 4 6 5 5 6 7 8]; t = [2 1 3 2 4 6 5 7 5 7 8 9 8 9]; w = [1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 1]; G= digraph(s,t...

quasi 3 anni fa | 0

Risposto
Filter cutoff frequency correction
% For digital filter fs = 1000; frp = 250; % freq at Rp [b, a] = cheby1(3, 0.5, frp/(fs/2)); [h, f] = freqz(b, a, 2048...

quasi 3 anni fa | 1

| accettato

Risposto
If statement in a for loop
There is no problem on your code. % Generate some data A0 = mat2cell(randn(40,40), [10 10 10 10], [10 10 10 10]) A = A0; for...

quasi 3 anni fa | 1

| accettato

Risposto
How can I add a column with labelining in a matrix
% Create a table with some data a = (1:10)'; b=rand(10, 1); c=randi([1,100], 10, 1); T = table(a, b, c) % Now add the label ...

quasi 3 anni fa | 1

| accettato

Risposto
Adding a colorbar to parallel coordinate plot
You can try to put a color bar in a subplot. a = randi([1,5],100,1); b = randi([3,9],100,1); c = randi([10,20],100,1); d = r...

quasi 3 anni fa | 2

| accettato

Risposto
set TileSpacing in reopened figure
t = tiledlayout(3,1); t.TileSpacing = 'none'; nexttile; plot(rand(10,1)); nexttile; plot(rand(10,1)); nexttile; plot(rand...

quasi 3 anni fa | 2

| accettato

Risposto
Generate all colour permutations of an image
x = imread("image.png"); image(x) % unique colors in the image uc = unique(reshape(x, numel(x)/3, 3), 'rows'); nc = size(uc,...

quasi 3 anni fa | 0

| accettato

Risposto
plotting the magnitude and phase response of a 3rd order low pass filter defined by the equation y(n)
% y(n) = 0.0181x(n)+0.0543x(n-1)+0.0543x(n-2)+0.0181x(n-3)+1.76y(n-1)-1.1829y(n-2)+0.2781y(n-3) b = [0.0181 0.0543 0.0543 ...

quasi 3 anni fa | 1

| accettato

Risposto
How to downsample a 3-D matrix data?
y = resample(A,65,1056,'Dimension',3);

quasi 3 anni fa | 0

| accettato

Risposto
4x1 4 matrix conversion to 4x4 4 matrix
a=[0; 0; 0; 0]; b=[1; 2; 3; 4]; c=[5; 6; 7; 8]; d=[0; 0; 0; 0]; eall =[a b c d]; for i = 1:4 e = reshape(eall(i,:), ...

quasi 3 anni fa | 0

Risposto
How to extract matrix from cell?
iwant = zeros(21, 41, 24, 28); % 32->59: 28 for i = 32:59; iwant(:, :, :, i) = myCell{i} ; end

quasi 3 anni fa | 0

Risposto
error using interp2
Looks like you should use "griddata" instead of "interp2" when you have irregular data points (x,y,z). "doc griddata" for detai...

quasi 3 anni fa | 1

Risposto
How to FIx non uniform Ranges in contour plots
[X,Y,Z] = peaks(50); levels = [-10 -8 -5 -2 0 4 6 8]; contourf(X,Y,Z, levels,'ShowText','on')

quasi 3 anni fa | 0

| accettato

Risposto
Resizing plots in tiledlayout()
tiledlayout(3,1); nexttile; plot(rand(10,1)) nexttile([2 1]) % span 2 rows and 1 colum in the tiledlayout plot(rand(20,1))

quasi 3 anni fa | 1

| accettato

Risposto
Unrecognized function or variable 'size'. in function called from script
Most likely, somewhere in your code you use "size" as a varibale name. Try "debstop error"; When error occurs, use "whos" to s...

quasi 3 anni fa | 1

Risposto
How to label columns in matrix?
% After the loop, you obtain ResultMtx. Convert it into a table with % column names. Then write the table ResultMtx = array2...

quasi 3 anni fa | 0

Risposto
How can I condense this block of code?
Consider this: % Rest/Control/Congruent/Incongruent thetaPower = NaN(length(restLFPs), 4); betaPower = NaN(length(restLFPs), ...

quasi 3 anni fa | 0

| accettato

Risposto
How can I create this matrix ?
A=rand(26, 5); B=rand(26, 7); C=rand(26, 8); for i=1:4 X{i} = [A, B(:,i) C(:,i)]; end X

quasi 3 anni fa | 0

| accettato

Risposto
random path between two nodes in undirected graph
% Generate a graph s = [1 1 1 2 2 3 3 4 5 5 6 7]; t = [2 4 8 3 7 4 6 5 6 8 7 8]; G = graph(s,t); h=plot(G) % find all pat...

quasi 3 anni fa | 1

Risposto
How to draw a random number from Cauchy Distribution with a particular mean and standard deviation?
Using the fact that Cauchy distribution is the Student's t distribution with dof=1. mu =4e5; sigma = 20; r = mu+sigma*trnd(1, ...

quasi 3 anni fa | 1

| accettato

Risposto
How can I locate the legend of specific points close to each of them in a plot ?
You can use "text" command to accomplish it. Code below show you the idea: % Generate some data (similar but different from yo...

quasi 3 anni fa | 1

Risposto
Why do I get correlation result NaN?
Use "fillmissing" to fill up the nans before computing the correlation. doc fillmissing for more details.

quasi 3 anni fa | 0

Risposto
How to delete nonzero values at the end of a matrix
M = [1 1 1; 0 2 2; 3 3 0; 4 4 0; 0 5 0] for i=1:size(M, 2) idx = find(M(:, i), 1, 'last'); M(idx+1:end, i) = nan; en...

quasi 3 anni fa | 1

| accettato

Risposto
Get Colormap Values Corresponding to Array Values
% rand cvars cvars = randi([10 450], [128, 1]); % You need to specify the number of colors to represent these cvars n = 512...

quasi 3 anni fa | 0

| accettato

Risposto
Eliminate Outliers and filtering signal
load RRData % median filter to remove outliers (for 1 channel) y1 = medfilt1(RRData.Strain_C_Fz, 7); plot(RRData.Time, RRData...

quasi 3 anni fa | 0

Risposto
array element concatenation, blank remove
p=[1,0,0,0,0,0,1,0]; n = length(p); q = sum(p.*10.^(n-1:-1:0))

quasi 3 anni fa | 1

Risposto
How to give output of Fortran code into MATLAB
There are two possible approaches: Use data file to communicate before FORTRAN code and matlab program. Use matlab to so a sys...

quasi 3 anni fa | 0

| accettato

Risposto
How to close any file without saving it?
Is "fclose all" what you want?

quasi 3 anni fa | 0

Carica altro