Answered

How to check ismember in a cell in Matlab?

result = cellfun(@(x)all(x == B{:}),List);

How to check ismember in a cell in Matlab?

result = cellfun(@(x)all(x == B{:}),List);

20 days ago | 0

Answered

Solving an equation with one variable

syms q a t E k1 k2 y eq = (q*a^4/(E*t^4)) == k1*y/t + k2*(y/t)^3; sol = solve(eq,y,'MaxDegree', 3);

Solving an equation with one variable

syms q a t E k1 k2 y eq = (q*a^4/(E*t^4)) == k1*y/t + k2*(y/t)^3; sol = solve(eq,y,'MaxDegree', 3);

22 days ago | 0

Answered

Reshaping 2d array

As in comment by Sebastian Bomberg's (for MATLAB >= R2016b): % Let A - your data of energy (150120 x 5 double) TT = array2time...

Reshaping 2d array

As in comment by Sebastian Bomberg's (for MATLAB >= R2016b): % Let A - your data of energy (150120 x 5 double) TT = array2time...

22 days ago | 0

| accepted

Answered

Matrix multiply with a function

i = [1:3;2,3,1;3:-1:1]; k = [.5;.78;.1]; f = [3;4;8]; d=[2 3 4;7 2 5;1 2 5]; l = k(i).*d + f(i); or l = kron(k(i),d) + k...

Matrix multiply with a function

i = [1:3;2,3,1;3:-1:1]; k = [.5;.78;.1]; f = [3;4;8]; d=[2 3 4;7 2 5;1 2 5]; l = k(i).*d + f(i); or l = kron(k(i),d) + k...

22 days ago | 1

| accepted

Answered

Combination of 4 Element

bl = cellfun(@(x)x(:)',bl,'un',0); n = numel(bl); ii = cell(n,1); for i = 1:n ii{i} = num2cell(nchoosek(1:4,i),2); end...

Combination of 4 Element

bl = cellfun(@(x)x(:)',bl,'un',0); n = numel(bl); ii = cell(n,1); for i = 1:n ii{i} = num2cell(nchoosek(1:4,i),2); end...

22 days ago | 0

Answered

Vectorisation of code for insertion of n x n matrices in a 3D array along the diagonal of a large matrix

A = full(gallery('tridiag',Z(n,1,:),cat(3,Z(1,1,1),Z(n,n,1:end-1)+Z(1,1,2:end),Z(n,n,end)),Z(1,n,:)));

Vectorisation of code for insertion of n x n matrices in a 3D array along the diagonal of a large matrix

A = full(gallery('tridiag',Z(n,1,:),cat(3,Z(1,1,1),Z(n,n,1:end-1)+Z(1,1,2:end),Z(n,n,end)),Z(1,n,:)));

23 days ago | 0

Answered

Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 3-by-3.

A = kron(diag([1 1],1),I) + kron(diag([1 1],-1),I) + kron(eye(3),T);

Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 3-by-3.

A = kron(diag([1 1],1),I) + kron(diag([1 1],-1),I) + kron(eye(3),T);

23 days ago | 0

Answered

How to select every nth value with the last value fixed from a column?

a = original_vector([100:100:4901,4901]);

How to select every nth value with the last value fixed from a column?

a = original_vector([100:100:4901,4901]);

23 days ago | 0

Answered

Integrating function of t over numerical values

F = str2func(vectorize(FUN)); Q = integral(F,0,6);

Integrating function of t over numerical values

F = str2func(vectorize(FUN)); Q = integral(F,0,6);

24 days ago | 0

Answered

How can I sort a matrix elementwise ?

A = [3, 4 ; 6, 2]; [m,~] = size(A); [B,i] = sort(A(:)); index = [mod(i-1,m) + 1, ceil(i/m)];

How can I sort a matrix elementwise ?

A = [3, 4 ; 6, 2]; [m,~] = size(A); [B,i] = sort(A(:)); index = [mod(i-1,m) + 1, ceil(i/m)];

24 days ago | 0

| accepted

Answered

How can I find the exact value of the corresponding point in specific longitude and latitude?

load('data.mat');load('lat.mat');load('lon.mat');load('xy.mat'); F1 = scatteredInterpolant(LAT,LON,data) F2 = scatteredInterpo...

How can I find the exact value of the corresponding point in specific longitude and latitude?

load('data.mat');load('lat.mat');load('lon.mat');load('xy.mat'); F1 = scatteredInterpolant(LAT,LON,data) F2 = scatteredInterpo...

26 days ago | 0

Answered

how to covert matlab time to actual time

T = readtable('SMPS1.xlsx','Sheet','Data','Range','1:481'); T.Time = dateshift(datetime(T.Date,'InputFormat','MM/dd/uuuu') + se...

how to covert matlab time to actual time

T = readtable('SMPS1.xlsx','Sheet','Data','Range','1:481'); T.Time = dateshift(datetime(T.Date,'InputFormat','MM/dd/uuuu') + se...

26 days ago | 0

| accepted

Answered

Generating Daily Values using Hourly Values

T = readtable('your_xlsx_file.xlsx'); t = datetime([T{:,1:4}, zeros(size(T,1),2)]); TT = timetable(T{:,end},'RowTimes',t) ; T...

Generating Daily Values using Hourly Values

T = readtable('your_xlsx_file.xlsx'); t = datetime([T{:,1:4}, zeros(size(T,1),2)]); TT = timetable(T{:,end},'RowTimes',t) ; T...

26 days ago | 1

| accepted

Answered

how can I find a specific data in time table in matlab?

i = diff(3*(data_mean_daily.tabrizmat7 < -3) + (data_mean_daily.tabrizmat7 > 1)) == -2; T_out = data_mean_daily([i;false]|[fals...

how can I find a specific data in time table in matlab?

i = diff(3*(data_mean_daily.tabrizmat7 < -3) + (data_mean_daily.tabrizmat7 > 1)) == -2; T_out = data_mean_daily([i;false]|[fals...

26 days ago | 0

| accepted

Answered

Display char matrix vertically

volt = [18 33 31 34 15 37 10.5 48 50 38 35 39 42 33 31 1 5 9 13 11 27 35 -1 46 22 6 19 36]; edges = -40:10:0; [~,~,j] = histco...

Display char matrix vertically

volt = [18 33 31 34 15 37 10.5 48 50 38 35 39 42 33 31 1 5 9 13 11 27 35 -1 46 22 6 19 36]; edges = -40:10:0; [~,~,j] = histco...

26 days ago | 0

Answered

Replace Number array with characters

volt = [18 33 31 34 15 37 10.5 48 50 38 35 39 42 33 31 1 5 9 13 11 27 35 -1 46 22 6 19 36]; edges = [-inf,0:10:40,inf]; frui...

Replace Number array with characters

volt = [18 33 31 34 15 37 10.5 48 50 38 35 39 42 33 31 1 5 9 13 11 27 35 -1 46 22 6 19 36]; edges = [-inf,0:10:40,inf]; frui...

27 days ago | 0

Answered

How to include a switch statement within a for loop?

% Parameters a_R = 0.0325; a_T = 0.0325; N_T = 164; N_R = 10; mu_0 = 4*pi*(10^-7); f_Array = [10000,20000,40000]; w = 2*p...

How to include a switch statement within a for loop?

% Parameters a_R = 0.0325; a_T = 0.0325; N_T = 164; N_R = 10; mu_0 = 4*pi*(10^-7); f_Array = [10000,20000,40000]; w = 2*p...

27 days ago | 0

| accepted

Answered

Integers without repeating consecutively

function [repPos, pinCodeFix] = pinCodeCheck(pinCode) lo = [true;diff(pinCode(:)) ~= 0]; repPos = find(~lo); pinC...

Integers without repeating consecutively

function [repPos, pinCodeFix] = pinCodeCheck(pinCode) lo = [true;diff(pinCode(:)) ~= 0]; repPos = find(~lo); pinC...

27 days ago | 0

Answered

How can I insert a smaller ones matrix into a larger zeros matrix?

AA = [5:12;ones(5,1)*[0 8 8 8 0 5 5 5]] AA(end-1:end,1:5) = 1; AA(4,7) = 7; eq7 = AA == 7; le7 = AA <= 7; gt7 = AA > 7; ...

How can I insert a smaller ones matrix into a larger zeros matrix?

AA = [5:12;ones(5,1)*[0 8 8 8 0 5 5 5]] AA(end-1:end,1:5) = 1; AA(4,7) = 7; eq7 = AA == 7; le7 = AA <= 7; gt7 = AA > 7; ...

28 days ago | 0

Answered

Averaging the data from a 3d matrix and populating it in a 2D matrix.

B = mean(A,3);

Averaging the data from a 3d matrix and populating it in a 2D matrix.

B = mean(A,3);

28 days ago | 0

| accepted

Answered

Filtering rows of a table by giving a constraint to a particular column

FiltereddataofTable = A(A.Alpha > 100,:);

Filtering rows of a table by giving a constraint to a particular column

FiltereddataofTable = A(A.Alpha > 100,:);

28 days ago | 0

| accepted

Answered

how to find nearest date and its corresponding value !

load('date.mat'); load('AOD.mat'); d = datetime(A,'ConvertFrom','datenum'); [lo,i] = ismembertol(AOD_440(:,1),A,1,'DataScale'...

how to find nearest date and its corresponding value !

load('date.mat'); load('AOD.mat'); d = datetime(A,'ConvertFrom','datenum'); [lo,i] = ismembertol(AOD_440(:,1),A,1,'DataScale'...

28 days ago | 0

| accepted

Answered

Help me with this problem

Theta = 75; % degrees va = 600; % km/h vb = 500; % km/h v_b_to_a = vb*exp(1i*(Theta/180 - 1)*pi) - va; V_b_to_a = abs(v_...

Help me with this problem

Theta = 75; % degrees va = 600; % km/h vb = 500; % km/h v_b_to_a = vb*exp(1i*(Theta/180 - 1)*pi) - va; V_b_to_a = abs(v_...

28 days ago | 0

Answered

Making a vector out of all even and odd numbers using for, if

lo = logical(mod(vect,2)); vect_even = vect(~lo); vect_odd = vect(lo);

Making a vector out of all even and odd numbers using for, if

lo = logical(mod(vect,2)); vect_even = vect(~lo); vect_odd = vect(lo);

28 days ago | 0

Answered

what loop to use to make the code\input repeat again ?

while true a=5 ; disp(' '); i = input('choose a number '); disp(' '); if i == a disp ('RR'); ...

what loop to use to make the code\input repeat again ?

while true a=5 ; disp(' '); i = input('choose a number '); disp(' '); if i == a disp ('RR'); ...

28 days ago | 0

Answered

how to replace the element with random number based if statement

mutC = mut1; [m,n] = size(mut1); pm = 0.5; rmi = rand(m,n); rCm = rbC+(raC-rbC).*rand(m,n); for i = 1:numel(mut1) if r...

how to replace the element with random number based if statement

mutC = mut1; [m,n] = size(mut1); pm = 0.5; rmi = rand(m,n); rCm = rbC+(raC-rbC).*rand(m,n); for i = 1:numel(mut1) if r...

29 days ago | 1

| accepted

Answered

How to write only non-NaN columns into Excel

T_in_Excel = T1(:,any(~isnan(T1{:,:}))); writetable(T_in_Excel, File_W)

How to write only non-NaN columns into Excel

T_in_Excel = T1(:,any(~isnan(T1{:,:}))); writetable(T_in_Excel, File_W)

29 days ago | 0