Answered
least-squares-regression
Read about polyfit. If you have the data x, y you can fit a line and get p1, p2 using polyfit. p = polyfit(x,y,1) ; p1 = p(1...

6 years ago | 0

Answered
3D Matrix manipulation
% to create random matrix A = rand(3,3,10) ; % To create random integers with in 100 B = randi(100,3,3,10) ; % To make on...

6 years ago | 0

| accepted

Answered
Finding a value based on multiple conditions of the next row
idx = find(DrivenTime(Procedure==2)) ; PReviousRow = idx(1)-1

6 years ago | 0

| accepted

Answered
Failing to reproduce material
Check the value of fileID...I think it is negative in your case. It is negative because, the correct path of the file is not pro...

6 years ago | 0

Answered
Colors and Symbols for Loop Iteration
figure surf(PDF_Hp) shading interp figure pcolor(PDF_Hp) shading interp figure plot(PDF_Hp) figure waterfall(PDF_Hp)

6 years ago | 0

Answered
How can I select region of interest in a video that works inside a loop?
vid=VideoReader('respiration.mp4'); fps= vid.FrameRate; nof= vid.NumberOfFrames; for k=1:nof; img=read(vid,k); if ...

6 years ago | 1

| accepted

Answered
mesh plot - Z must be a matrix - problem resolved
% Data T=300; k=1.38064852e-23; Ea=7.2*10^(-21); Ed=7.2*10^(-21); Nv=2.5*10^(25)*((0.59*T/300)^(3/2))*10^(-6); Nc=2.5*10^(...

6 years ago | 1

| accepted

Answered
plot curve in matlab
Define qa first....and then use your formula. Example: m = 100 ; qa= linspace(0,2*pi,m) ; % give your range here h = cos(...

6 years ago | 0

Answered
A function that inserts an element into an array
Hints: To get length of an array use length. To get dimensions use size. If you have an array a, to access ith element: a(i) ...

6 years ago | 0

| accepted

Answered
Ellipse and circle plot
C = [0 0] ; % center a = 2 ; % major axis e = 0.4 ; % eccentricity b = a*sqrt(1-e^2) ; % minor axis % R = 2; ...

6 years ago | 1

Answered
How to paint some pixels with a specific color?
idx = Best_delta_map<0 ; figure lag_map = pcolor(longq,latq,Best_delta_map); hold on plot(longq(idx),latq(idx),'.r') %tpma...

6 years ago | 0

Answered
How to create a loop where the user puts in new values which append to an array?
Read about input, for loop. N = input("Enter the number of values:") ; % say 10 T = zeros(N,1) ; % Temperature for i = ...

6 years ago | 0

Answered
how to select node of mesh grid one by one
X =-5:1:5 ; Y =-5:1:5 ; [Xc,Yc]=meshgrid(X,Y); coor = [X(:) Y(:)] ; Select your required node from ...

6 years ago | 0

Answered
How do I show the variables the users' inputted in a disp or fprintf fucntion?
prompt = "Hey user, input a number: "; num = input(prompt) ; fprintf("User, you have entered %f\n",num)

6 years ago | 0

Answered
Ho do I make a matrix with point data?
Let A be your m*3 data matrix. x = A(:,1) ; y = A(:,2) ; z = A(:,3) ; %%structured xi = unique(x) ; yi = unique(y) ; [X,Y...

6 years ago | 0

| accepted

Answered
How do I ask a a user to input a number between 1 and 2000, then show a response whether their input is valid or invalid?
prompt= "Input a number in the range [1 2000]: " ; num = input(prompt) ; while (num<1 || num >2000) num = input(prompt) ;...

6 years ago | 0

Answered
repeat elements of row matrix li [1 2 2 3 3 3 4 4 4 4 n...... n times]
n = 6 ; p = cumsum(10.^(0:n-1)) ; iwant = p.*(1:n)

6 years ago | 1

Answered
compare two arrays then compare them to create a new one
A = [ 1 4 3 2 3] B = [1 2 2 4 3] C = A==B Also read about isequal

6 years ago | 1

Answered
How to plot Multiple trend-lines on one scatter plot
You can pick those respective points and fit a curve to plot the trend. Let x,y be your points. x1 = x(x<=15) ; % pick points...

6 years ago | 0

Answered
how can I creat file name otomaticaly
for i = 50:50:3000 fname = [num2str(i),'.dat'] end

6 years ago | 0

Answered
How to plot a vector field with coloured arrows?
https://in.mathworks.com/matlabcentral/fileexchange/3225-quiverc https://in.mathworks.com/matlabcentral/fileexchange/71903-cqu...

6 years ago | 0

| accepted

Answered
How to replace every element of a matrix with another column matrix?
You can use this function: https://in.mathworks.com/help/deeplearning/ref/ind2vec.html

6 years ago | 1

Answered
Comparison of entries of one data set (just one column) with multiple columns of second data set
To check whether all the values are less than or greather than a certain value/array. You can get the logical indices and use nn...

6 years ago | 0

Answered
Roll a 6-sided die until you have rolled a total of 25 6's.
count = 0 ; iwant = zeros([],1) ; i = 0 ; while count ~= 25 i = i+1 ; N = randi(6) ; iwant(i) = N ; if N == 6...

6 years ago | 0

| accepted

Answered
storing and appending in a for loop
% vec,Rep,Pos = some data X = cell([],1) ; Y = cell([],1) ; k = 1 for i = 1:length(vec) time = (data(vec(i+1))); ...

6 years ago | 0

| accepted

Answered
HOW CAN I GET THE COMPLEX ROOTS ONLY OF A POLYNOMIAL ?
idx = imag(o)~=0 ; o(idx) Also read bout isreal, iscomplex.

6 years ago | 0

Answered
Data picking from grid
I have edited the code for your given points so that you can get the points for each grid. x = -130.7:0.1:-129.7 ; y = 45.6:...

6 years ago | 0

| accepted

Answered
Drawing 3 D for 3 data sets
Whay you get is this: X = [65 70 75 80 85 90 95 100]; Y = [36 38 40 42 44 46 50 54]; Z = [1792.373894 1178.621038 685.707800...

6 years ago | 0

| accepted

Answered
Plot with markers defined
x = -2:0.4:2; for a= [2 3 4] ; if a == 2 M = {'-*r'} ; elseif a == 3 M = {'-db'} ; ...

6 years ago | 0

Answered
prove point A is not point B matlab
Read about isequal. A = [6 -9] ; B = [-9 6] ; val = isequal(A,B)

6 years ago | 0

Load more