Beantwortet
Non-loop comparison of 3 - D matrices using "find"?
Let A - your 3-D matrix with size that is 21 x 751 x 1500 B - your "flag" array with size that is 1 x 751 x 1500 for |MA...

etwa 8 Jahre vor | 0

Beantwortet
How to place NaN at diagonal position in cell array?
a={[],-1,-1,0.8,-0.7,[],[]; [],[],0.9,1,[],-0.9,0.6; -1,[],[],0.9,0.2,[],0.8}; [m,n] = size(a); z = sort([repmat(...

etwa 8 Jahre vor | 0

| akzeptiert

Beantwortet
comparing elements of a cell array based on another cell array
a1 = {[2,5];[1,3,4]}; a2= {[1,4],[1,5],5,4,[3,5,2]}; n = numel(a1); out = cell(n,1); nn = cellfun(@numel,a2); ...

etwa 8 Jahre vor | 0

| akzeptiert

Beantwortet
how to implement the following table contents in N-dimensional lookup table?
function out = Error_status(Psi,Te,Sector) [T,S,ps] = ndgrid([1, 0, -1],1:6,0:1); x(:,:,1) = string( {'110' '...

etwa 8 Jahre vor | 2

Beantwortet
How to display my outputs which one of them is complex numbers and other ones are just 2 digit number in a vertical form side by side. one is "output" and the other ones is "rows" and "columns" in matlab
lo = imag(A) ~= 0; output = A(lo); [rows,cols] = find(lo); out = table(output,rows,cols);

etwa 8 Jahre vor | 0

| akzeptiert

Beantwortet
Attempt to reference field of non-structure array.
Maybe this? x=2; D=[1 0 1 0]; X=[1;x;x.^2;x.^3]; dx=D*X; gx=1+x+x.^3;

etwa 8 Jahre vor | 0

Beantwortet
Reshape matrix in the desired form
a = [1 2 3 4] ; b = [5 6 7 8] ; B = [repmat(a,1,4);repelem(b,4)]; or reshape(permute(A,[2,1,3]),[],2)';

etwa 8 Jahre vor | 0

Beantwortet
How can I skip some rows in Matlab ?
out = You_array(1:2:end,:);

etwa 8 Jahre vor | 2

| akzeptiert

Beantwortet
Parsing a data set into multiple arrays based on value?
a = randi(10000,20,1); % Let a - your array lo = a >= 1000; ii = cumsum(diff([0;lo(:)]) == 1); out = accumarray(i...

etwa 8 Jahre vor | 0

| akzeptiert

Beantwortet
How to process a large matrix of size 28x28x11684?
Just: z = sort(a); With loop: k = size(a,3); z = a; for ii = 1:k z(:,:,ii) = sort(a(:,:,ii)); end

etwa 8 Jahre vor | 0

| akzeptiert

Beantwortet
How can I vectorize this function with nested FOR loop?
% MATLAB >= R2016b z = - 20 * exp( - 0.2 * sqrt( .5 * sum( x(:).^2 + y(:)'.^2 ) ) ); % MATLAB <= R2016a [...

etwa 8 Jahre vor | 2

| akzeptiert

Beantwortet
How to get values in an 8x8x4096 matrix?
Let M - your array [8x8x4096]. One variant: [m,n,k] = size(M); x = [1,2,2]; y = [2,2,1]; out = M(sub2ind([m...

etwa 8 Jahre vor | 0

| akzeptiert

Beantwortet
Finding neighbour values average of the 2d data set
x1 = floor(x(:))+1; [ii,g] = findgroups(x1); out = [g,splitapply(@mean,y(:),ii)]; Second variant of the output. ...

etwa 8 Jahre vor | 1

| akzeptiert

Beantwortet
Hi, I would like create a vector using a for loop.
n = 7; P = 1e3; X = P * 1e-3.^(0:n);

etwa 8 Jahre vor | 1

Beantwortet
Converting 2D matrix to 3D matrix
out = reshape(your_matrix,size_of_your_new_3D_matrix)

etwa 8 Jahre vor | 0

| akzeptiert

Beantwortet
Why am I getting an error that matrices must agree?
prompt= 'State the Area: '; Area = input(prompt); prompt= 'State the Straight Cost: '; StrCo = input(prompt); prom...

etwa 8 Jahre vor | 1

Beantwortet
Search matrix for array of values and place results into another
t = ismember(A',B); Ct = C'; ii = sort(t,'descend'); out = double(ii); out(ii) = Ct(t); out(~ii) = -1; out =...

etwa 8 Jahre vor | 0

Beantwortet
How can I calculate Centriod from a sets of location coordinate value(x,y)?
xy_centroid = mean([X,Y]) or >> T = readtable('your_xls_file.xls'); >> XY_centroid = mean(T{:,:}) XY_centroid = ...

etwa 8 Jahre vor | 0

| akzeptiert

Beantwortet
Dynamically adding elements into an array every nth element based on user-defined inputs, while preserving array order
S = 1:7; % original sequence ir = 2 ; % insert every "#" times io = 9999; ...

etwa 8 Jahre vor | 1

Beantwortet
If Loop for specific condition
t = -5:0.5:50; tt = [-inf,10,20,30,inf]; f = {@(t)11*t.^2 - 5*t; @(t)1100-5*t; @(t)50*t + 2*(t-20).^2; ...

etwa 8 Jahre vor | 1

Beantwortet
how to multiply 2 matrix A of dimension 5*4 and matrix B of dimension 4*1 upto k times?
m=5; n=4; k=3; x = 2*(rand(n,1) > .5) - 1; p = rand(m,n,k); y = squeeze(sum(bsxfun(@times,p,reshape(x,1,[])...

etwa 8 Jahre vor | 1

Beantwortet
find local maxima without using findpeaks()
Please use function |diff|. for example: a = rand(15,1); t = diff(a); lo = t > 0; ii = strfind(lo(:)',[1,0]...

etwa 8 Jahre vor | 2

Beantwortet
How do I write a equation script that uses 2 sets of data.
dvt = diff([v,t]); a = dvt(:,1)./dvt(:,2);

etwa 8 Jahre vor | 1

| akzeptiert

Beantwortet
I have an hourly meteorological data screenshot attached which i need to convert to average daily data. Since I have a long period of data it is difficult to do it in excel. If anyone knows how to code it in matlab pls let me know
T = readtable('your_xls_file.xls'); t = datetime(strcat(T{:,2},'_',T{:,1}),'i','MM/dd/uuuu_HH:mm'); TT = table2timetable...

etwa 8 Jahre vor | 0

| akzeptiert

Beantwortet
How to effectively run loops and save time in computation? I have a matrix of size 'm' and run five loops from 1 to m. The logic is explained below. How to optimize the code and save time of calculation.
a = abs(H + permute(H,[3,2,1])).*permute(diag(nan(m,1))+ones(m),[1,3,2]); a(a == 0) = nan; b = 1.1926*median(median(a,3,...

etwa 8 Jahre vor | 1

| akzeptiert

Beantwortet
Computational neuroscience - I have a 116x116x226 I need to calculate the eigenvalues for this array can anyone help me?
d = xlsread('path_to_your_file\NT example.xls'); [m,n] = size(d); ii = rem(0:n-1,m)+1 ~= 1; nn = 1:n; n1 =...

etwa 8 Jahre vor | 1

Beantwortet
Half hour data to monthly average
d = 10*rand(275,48) - 5;% let d - your data -> one row - one day date1 = datetime(2018,2,20 + (0:size(d,1)-1)') ; % Enter d...

etwa 8 Jahre vor | 0

Beantwortet
Adding rows and column to existing inter dependency matrix
s = string({'CR';'E';'R';'S';'SR'}); [x,y] = ndgrid(1:20,[2,5]); str = s([2;3;2;4;y(:)]) + ([101;1;106;1;x(:)] + (0:4))...

etwa 8 Jahre vor | 0

| akzeptiert

Beantwortet
moving average of unevenly spaced time data
t = randi([3 5],6,1); % your time intervals in seconds n = cumsum(t); s = rand(n(end),1); s = s.*(s < .3); % your signa...

etwa 8 Jahre vor | 1

| akzeptiert

Mehr laden