Answered
How can I write N-dimensional numeric array into excel sheet?
Why you want to write it in different pages? You can write in a single sheet; so that it woul dbe easy while reading. LEt A be y...

4 years ago | 0

| accepted

Answered
Why is this generating a numerical array and not an array of cells?
REad about the function diff. It needs an array with atleast 1x2 dimensions. You are giving only one number as input. So diff gi...

4 years ago | 0

| accepted

Answered
y =kx^n can anybody solve this
data = [1.76E-02 1.79E+07 1.92E-02 2.39E+07 2.17E-02 2.98E+07 3.92E-02 3.58E+07 1.32E-01 5.97E+07] ; x = data(:,1...

4 years ago | 0

Answered
Read csv files and save the plots (.bmp format)
clearvars indir = '.'; %current directory outdir = 'C:\Users\gagan\Downloads\testing_lab\Stage-1 testing\plots'; %where to...

4 years ago | 0

Answered
Matlab simulation for planet motion
t = 0; m1 = 1; m2 = 2; G = 1; pos01 = [1 2 3]; pos02 = [4 5 6]; pos1 = zeros([],3) ; pos2 = zeros([],3) ; iter = ...

4 years ago | 1

Answered
Add grid lines onto the 3D mesh plot
[X,Y,Z] = peaks(1000) ; % data for demo surf(X,Y,Z) % this will be black shading interp % this will remove black lines...

4 years ago | 0

Answered
How to put these values into one array ?
x = 1:8 ; f = [repmat('%d,',1,length(x)-1),'%d\n'] ; fprintf(f,x)

4 years ago | 0

| accepted

Answered
How can the following code be optimized / vectorized?
I think pdist2, this inbuilt function will work for you. T = readtable('Sample.xlsx') ; A = table2array(T) ; A = A(:,3:5) ...

4 years ago | 0

Answered
Row and Column reduction of
A = rand(4) iwant = zeros(6) ; iwant(1:4,1:4) = A B = iwant ; iwant = B(1:4,1:4)

4 years ago | 0

| accepted

Answered
Having difficulties in generating correct legend in subplot
You need not to use loop. I have edited the code, check it. n=[300 600]; for m=1:length(n) t_0=0; t_n=3; h=(t_...

4 years ago | 0

Answered
How to call a function to read some files from a specific folder?
thepath = 'D:\...\multiparts test2' ; filename1 = [thepath,filesep,'lineinjection.dpm'] ; filename2 = [thepath,filesep,'linei...

4 years ago | 0

| accepted

Answered
I want to find area under the curve
x=[0.4166 0.5882 1.0526 2.3419 3.5273 9.433]; y=[0.912 0.933 0.9475 0.9677 0.984 0.999] ; % Make the curve closed P = [ma...

4 years ago | 0

Answered
How can I generate n*(n^2) matrix with n 1's per row, indented n times?
n = 4 ; A = zeros(n,n,n) ; for i = 1:n A(i,:,i) = ones(n,1) ; end A = reshape(permute(A,[1,2,3]),size(A,2),[])

4 years ago | 0

| accepted

Answered
How to get the multiplication of elements in a row vector by using for loop
% create a vector A = [-2,4,9,-5,1]; Mult = 1; % <----- this should be 1 % create a for loop for i = 1:length(A) Mul...

4 years ago | 1

| accepted

Answered
How to generate a sequence in MATLAB?
m = 10 ; n = 10 ; % decide till what number you want to end C1 = (1:n)' ; C2 = m/2-(0:n-1)' ; C3 = [m ; m/2+(1:n-1)'] ; ...

4 years ago | 1

| accepted

Answered
How to calculate R^2 based on external linear equation?
Substitute your x in th equation y = mx+c, get (x1,y1) and let (x0,y0) be your old existing values. Then you can use regressio...

4 years ago | 0

Answered
Finding maximum value and its location in an array
REad about the function max. If v is your array. [val,idx] = max(v)

4 years ago | 0

Answered
Create txt file from each row of Matrix
A = rand(3,10) ; for i = 1:3 fid = fopen([num2str(i),'.txt'],'w') ; fprintf(fid,'%f\n',A(i,:)) ; fclose(fid) ; ...

4 years ago | 2

Answered
How to do a circle with triangular mesh?
You may refer this: https://in.mathworks.com/matlabcentral/fileexchange/57824-mesh-a-circle-with-quadrilaterals

4 years ago | 1

Answered
How to remove specific rows
idx = a == 0 ; % find indices of zeroes in a b(idx) = [] ; % remove the respective values from b If a is floating point...

4 years ago | 1

| accepted

Answered
How do i write this code for different timestep like this code is for 3600 and i want to use different timesteps like 1800,900,450
dt = [3600 1800 900 450] ; for i = 1:length(dt) nsteps = 12; t = zeros (nsteps,1); A = zeros (nsteps,1); B = zeros(nsteps, ...

4 years ago | 0

Answered
How to crop unwanted data from surfplot?
You should be having vertices of the triangle or your required region. USe inpolygon to get the indices of the coordinates which...

4 years ago | 0

Answered
How to plot 3D surface with the given points in excel
T = readtable(myexcelfile) ; x = T.(1) ; y = T.(2) ; z = T.(3) ; %%structured xi = unique(x) ; yi = unique(y) ; [X,Y] = me...

4 years ago | 1

| accepted

Answered
How to extract data from an array
Let x be your signal and val be yout threshold. val = 50000 ; tol = 10^-3 ; idx = find(abs(sig-val)<=tol) ; % this gives th...

4 years ago | 0

Answered
Create a double identity matrix matlab
M=12; K=eye(M); K(2:1+size(K,1):end) = 1

4 years ago | 0

Answered
Combining two vectors into a new one
A = rand(3) ; B = rand(2) ; idx = knnsearch(B(:),A(:)) Also have a look on ismember, ismembertol.

4 years ago | 1

Answered
Input data from another script
x = 1:1:100 ; for i = 1:length(x) xi = x(i) ; % input xi to your function and do what you want end

4 years ago | 0

Answered
How to apply dec2bin to char array?
a ='1234567'; dec2bin(str2num(a))

4 years ago | 1

Answered
Error using cos Not enough input arguments. HELP
(cos(5*pi/6))^2.*sin(7*pi/8)^2.+tan(pi/6*ln8)/sqrt(7)

4 years ago | 1

| accepted

Load more