Answered

Need to create a for loop for this problem

idx = (0:128:2048)' ; I = [idx(1:end-1)+1 idx(2:end)] ; for i = 1:size(I,1) I(i,:) end

Need to create a for loop for this problem

idx = (0:128:2048)' ; I = [idx(1:end-1)+1 idx(2:end)] ; for i = 1:size(I,1) I(i,:) end

1 month ago | 0

Answered

How to add a scalar to the first element in each row of an array?

A = rand(5,6) ; % random data [m,n] = size(A) ; iwant = zeros(m,n+1) ; iwant(:,2:end) = A ; % Calculate the first element...

How to add a scalar to the first element in each row of an array?

A = rand(5,6) ; % random data [m,n] = size(A) ; iwant = zeros(m,n+1) ; iwant(:,2:end) = A ; % Calculate the first element...

1 month ago | 1

| accepted

Answered

How to run a for loop multiple times on some images?

n = repmat(1:4,1,8) ; idx = randsample(length(n),length(n)) ; n = n(idx) ; Run a loop on n, 1:4 stand for the four images res...

How to run a for loop multiple times on some images?

n = repmat(1:4,1,8) ; idx = randsample(length(n),length(n)) ; n = n(idx) ; Run a loop on n, 1:4 stand for the four images res...

1 month ago | 0

Answered

How to assign 255 pixel value to Index Values and crop image in MATLAB

x0 = min(rows1) ;x1 = max(rows1) ; y0 = min(columns1) ; y1 = max(columns1) ; I = imcrop(grayImage,[y0 x0 (y1-y0) (x1-x0)]) ...

How to assign 255 pixel value to Index Values and crop image in MATLAB

x0 = min(rows1) ;x1 = max(rows1) ; y0 = min(columns1) ; y1 = max(columns1) ; I = imcrop(grayImage,[y0 x0 (y1-y0) (x1-x0)]) ...

1 month ago | 0

Answered

slipting sata manually into train, validation and test sets, then using fitcnet and testing accuracy

Refer here: https://in.mathworks.com/matlabcentral/answers/395136-how-to-divide-a-data-set-randomly-into-training-and-testing-da...

slipting sata manually into train, validation and test sets, then using fitcnet and testing accuracy

Refer here: https://in.mathworks.com/matlabcentral/answers/395136-how-to-divide-a-data-set-randomly-into-training-and-testing-da...

1 month ago | 0

Answered

devide data into train set, validation set and test set

Read about dividerand. Also have a look on: https://in.mathworks.com/matlabcentral/answers/395136-how-to-divide-a-data-set-rand...

devide data into train set, validation set and test set

Read about dividerand. Also have a look on: https://in.mathworks.com/matlabcentral/answers/395136-how-to-divide-a-data-set-rand...

1 month ago | 0

| accepted

Answered

Arrow in quiver plot does not show with change of position

You may consider dividng the component of vector with the magnitude and plot. spacing = 0.1; [x,y] = meshgrid(-1:spacing:1); ...

Arrow in quiver plot does not show with change of position

You may consider dividng the component of vector with the magnitude and plot. spacing = 0.1; [x,y] = meshgrid(-1:spacing:1); ...

1 month ago | 0

Answered

Pcolor plot question. gradational color change.

x = 1:20 ; y = TIME ; % 81x1 array Z = Y ; % 81x20 array pcolor(x,y,Z) ; % if required transpose Z

Pcolor plot question. gradational color change.

x = 1:20 ; y = TIME ; % 81x1 array Z = Y ; % 81x20 array pcolor(x,y,Z) ; % if required transpose Z

1 month ago | 0

Answered

How to; For loop of angle in projectile motion

You are not updating the theta0 to find the range. You need to input theta0 to the function. clc; clear all ; g = 9.82; %grav...

How to; For loop of angle in projectile motion

You are not updating the theta0 to find the range. You need to input theta0 to the function. clc; clear all ; g = 9.82; %grav...

1 month ago | 1

Answered

Plot a 3d surface

T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1101840/Ex12.xlsx') ; data = table2array(T) ; x =...

Plot a 3d surface

T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1101840/Ex12.xlsx') ; data = table2array(T) ; x =...

1 month ago | 0

Answered

Ploting a 3d figure by exel data

T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1101815/Ex12.xlsx') ; data = table2array(T) ; x =...

Ploting a 3d figure by exel data

T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1101815/Ex12.xlsx') ; data = table2array(T) ; x =...

1 month ago | 0

Answered

How to save outputs from previous iterations and plot

n = 180 ; a = zeros(1,n) ; a(1) = 20000; R = 0.06; r = R/12; z = amortization(a(1),R,n); for i = 2:n b = a(i-1)*r...

How to save outputs from previous iterations and plot

n = 180 ; a = zeros(1,n) ; a(1) = 20000; R = 0.06; r = R/12; z = amortization(a(1),R,n); for i = 2:n b = a(i-1)*r...

1 month ago | 0

| accepted

Answered

How to sort all rows in one table based on one row from the table and another table

Read about ismember T1 = {'Mom', 'Dad' 'Sister'} ; T2 = {'Sister', 'Mom', 'Dad'}; [c,ia] = ismember(T1,T2) ; T2(ia) Now use...

How to sort all rows in one table based on one row from the table and another table

Read about ismember T1 = {'Mom', 'Dad' 'Sister'} ; T2 = {'Sister', 'Mom', 'Dad'}; [c,ia] = ismember(T1,T2) ; T2(ia) Now use...

1 month ago | 0

Answered

Spline interpolation of 4D matrix

A = rand(450,450,50,3) ; B = zeros(size(A)) ; for i = 1:450 for j = 1:450 for k = 1:50 B(i,j,k,:) ...

Spline interpolation of 4D matrix

A = rand(450,450,50,3) ; B = zeros(size(A)) ; for i = 1:450 for j = 1:450 for k = 1:50 B(i,j,k,:) ...

2 months ago | 0

Answered

How to take average of such an array?

% Make data for demo A = cell(6,2) ; for i = 1:6 for j = 1:2 A{i,j} = rand(1,10) ; end end % Get mean i...

How to take average of such an array?

% Make data for demo A = cell(6,2) ; for i = 1:6 for j = 1:2 A{i,j} = rand(1,10) ; end end % Get mean i...

2 months ago | 0

Answered

How to get sample names from scatter plot in classification learner

If you have feature1, feature2 in hand, you can use knnsearch to get the index and then check the sample name. If you are havi...

How to get sample names from scatter plot in classification learner

If you have feature1, feature2 in hand, you can use knnsearch to get the index and then check the sample name. If you are havi...

2 months ago | 0

Answered

Why does not string(f.name) work, f = dir(folder)?

folder = "~/Documents" f = dir(folder) ; % f is a structure for i = 1:length(f) f(i).name end

Why does not string(f.name) work, f = dir(folder)?

folder = "~/Documents" f = dir(folder) ; % f is a structure for i = 1:length(f) f(i).name end

2 months ago | 1

Answered

Plotting the function on a Sphere?

r = 1 ; th = linspace(0,2*pi) ; phi = linspace(0,pi) ; [T,P] = meshgrid(th,phi) ; X = r*cos(T).*sin(P) ; Y = r*sin(T).*sin(...

Plotting the function on a Sphere?

r = 1 ; th = linspace(0,2*pi) ; phi = linspace(0,pi) ; [T,P] = meshgrid(th,phi) ; X = r*cos(T).*sin(P) ; Y = r*sin(T).*sin(...

2 months ago | 0

Answered

Generate a sequence/vector of randomized letters

a='A':'Z'; letters= a(randi(numel(a), 1, 10)) iwant = strjoin(cellstr(letters'),',')

Generate a sequence/vector of randomized letters

a='A':'Z'; letters= a(randi(numel(a), 1, 10)) iwant = strjoin(cellstr(letters'),',')

2 months ago | 1

| accepted

Answered

Plot 2-d contour of 3D dataset

How about this? T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1099910/data_16082022.csv') ; x ...

Plot 2-d contour of 3D dataset

How about this? T = readtable('https://in.mathworks.com/matlabcentral/answers/uploaded_files/1099910/data_16082022.csv') ; x ...

2 months ago | 0

Answered

Solve the following differential equations using Matlab.

syms p(x) ode = diff(p)+8*p==9 ; cond = p(0)==-1 ; pSol(x) = dsolve(ode,cond)

Solve the following differential equations using Matlab.

syms p(x) ode = diff(p)+8*p==9 ; cond = p(0)==-1 ; pSol(x) = dsolve(ode,cond)

2 months ago | 0

Answered

Compare 2 Matrixs Different Dimension With For

A = [1 1 1 1 2 4 2 3 2 1]; B = [4 1 3 1 2]; idx = A'==B

Compare 2 Matrixs Different Dimension With For

A = [1 1 1 1 2 4 2 3 2 1]; B = [4 1 3 1 2]; idx = A'==B

2 months ago | 0

| accepted

Answered

Create an image from x and y locations with greyscale value

data = [0 0 255 0 0.5 70 0 1 111 0.5 0 26 0.5 0.5 26 0.5 1 255 1 0 108 1 0.5 26 1 1 70] ; x = data(:,1) ; y = data(:...

Create an image from x and y locations with greyscale value

data = [0 0 255 0 0.5 70 0 1 111 0.5 0 26 0.5 0.5 26 0.5 1 255 1 0 108 1 0.5 26 1 1 70] ; x = data(:,1) ; y = data(:...

2 months ago | 0

Answered

getting x and y values and writing them

Already you have data in hand. If you want to write that into a file use: data = [t(:) x(:)] ; writematrix(data,'data.txt') ;...

getting x and y values and writing them

Already you have data in hand. If you want to write that into a file use: data = [t(:) x(:)] ; writematrix(data,'data.txt') ;...

2 months ago | 0

| accepted

Answered

How to draw phase portrait

plot(t,xa(:,1)) In the baove use your required index for the column and plot. You can use quiver, if you have vectors. Assumin...

How to draw phase portrait

plot(t,xa(:,1)) In the baove use your required index for the column and plot. You can use quiver, if you have vectors. Assumin...

2 months ago | 0

Answered

3D dose plot and color wash

T = readtable('myfile.xlsx') ; scatter3(T.(1),T.(2),T.(3),[],T.(4),'filled')

3D dose plot and color wash

T = readtable('myfile.xlsx') ; scatter3(T.(1),T.(2),T.(3),[],T.(4),'filled')

2 months ago | 0

| accepted

Answered

I HAVE A KEY WHICH IS 1*16 MATRIX. HOW CAN I DETERMINE IT'S BIT SIZE?

KEY=[0 0 1 0 3 12 8 7 7 8 12 3 0 1 0 0] ; a = single(KEY) ; iwant = whos('a')

I HAVE A KEY WHICH IS 1*16 MATRIX. HOW CAN I DETERMINE IT'S BIT SIZE?

KEY=[0 0 1 0 3 12 8 7 7 8 12 3 0 1 0 0] ; a = single(KEY) ; iwant = whos('a')

2 months ago | 0

| accepted

Answered

Create a structure of a field in the workspace

You can save them into a matfile and access, as you like. A = 1 ; B = 2; C = 3 ; save Test.mat ; S = matfile('Test.ma...

Create a structure of a field in the workspace

You can save them into a matfile and access, as you like. A = 1 ; B = 2; C = 3 ; save Test.mat ; S = matfile('Test.ma...

2 months ago | 0

Answered

append data to the already existed .txt file horizontally

T1 = readtable('file1.txt') ; T2 = readtable('file2.txt') ; T = [T1 T2] ; writetable(T,'file.txt')

append data to the already existed .txt file horizontally

T1 = readtable('file1.txt') ; T2 = readtable('file2.txt') ; T = [T1 T2] ; writetable(T,'file.txt')

2 months ago | 0

Answered

overlap the same data 5 times

Let M be the matrix in your mat file. matFiles = dir('*.mat') ; N = length(matFiles) ; iwant = []; for i = 1:N S = ma...

overlap the same data 5 times

Let M be the matrix in your mat file. matFiles = dir('*.mat') ; N = length(matFiles) ; iwant = []; for i = 1:N S = ma...

2 months ago | 0