Answered
Is there a way to overcome For loops for fast processing?
See attached script clc, clear A = imread('masson.jpg'); subplot(1,2,1) imshow(A) RGB = [40 120 40]; % color you w...

6 years ago | 1

Answered
Plotting Contour with point coordinates
Arc-length interpolation L = sqrt(diff(x).^2 + diff(y).^2); t = [0 cumsum(L)]; t1 = linspace(0,t(end),50); x1 = spline(t,x,t...

6 years ago | 0

| accepted

Answered
How does the function "mesh" work?
Since you didn't specify X and Y for mesh() [m,n] = size(b); [X,Y] = meshgrid(1:m,1:n); mesh(X,Y,b) Is that you wanted to kn...

6 years ago | 0

Answered
Is there a way to reduce compilation time for this segment?
See if it works

6 years ago | 0

| accepted

Answered
How to plot this implicit function
Try symbolic expression clc,clear alpha=1.5; A=0.0207; gamma=0.25; syms beta eps x = (beta-alpha*(beta-gamma)+sqrt((beta-a...

6 years ago | 0

| accepted

Answered
Plotting infinite series with set of parameters
Looks like simple sin() or cos(): What do you think? Try my script, i think i reached a success

6 years ago | 1

| accepted

Answered
2D velocity plot
Use quiver()

6 years ago | 0

Answered
Evaluate the smoothness of curve
I used find() function to exract all white pixels. Reduced number of points and interpolated them to get smooth curve (look HERE...

6 years ago | 1

| accepted

Answered
Sort of peak analysis
How i found start and end of each peak % generate some data x = linspace(-1,17); y = sin(x); y = y.*(y>0); thresh = 0...

6 years ago | 1

| accepted

Answered
Simulate what happens to a stock price between two periods of time
I think you should divide your taks into two parts: increase stock decrease stock for loop can be used in the first part: y ...

6 years ago | 0

Answered
How to find the position of an element in a vector
Use find()

6 years ago | 0

Answered
How to find intersection of 2 non-equally sized arrays in matlab
Use polyxpoly() or intersections

7 years ago | 0

Answered
Writing a script for the Equation Of Motion
Some examples of throwing. MAybe you can find them usefull for your bullet simulation

7 years ago | 0

Answered
For command in function
You can use pdist2() [X,Y] = meshgrid(2:4); x = X(:); y = Y(:); D = pdist2(rowsncolumns,[x y]); % D(:,1) - first column of ...

7 years ago | 0

| accepted

Answered
How to graph a patch that follows a line?
I found boundary points and moved them down a bit zq(isnan(zq)) = 1000; % replace NaN with big number ix = find(diff...

7 years ago | 0

| accepted

Answered
Create a for cycle over an array
It is a job for cumsum() function: D = [2 3 4 4 5 6 7 3 ]; tin1 = [0 2 5 9 13 18 24 31]; tin2 = [2 5 9 13 18 24 31...

7 years ago | 0

Answered
Overlapping rectangles problem in an image
Use inpolygon() to check if point is in rectangle

7 years ago | 0

Answered
Problem in calculating the derivative of a cost function
Try this [U,V,W] = meshgrid(u,v,w); %Computing the vector of B-splines Bu(:,:,:,1) = ((1 - U).^3)/6; Bu(:,:,:,2) = (3*...

7 years ago | 1

| accepted

Answered
How to treat x axis made of 2 data sets as continuous
Use interp1() x0 = ... y10 = interp1(x1,y1,x0); y20 = interp1(x2,y2,x0); y10 - y20

7 years ago | 1

| accepted

Answered
Shape optimization of a mechanical object
Area of a cylinder crossection is: (r is radius) To calculate a load: (F - force, P - pressure) Example P = 620 MPa (maximu...

7 years ago | 0

Answered
Averaging the previous 5 values of every 30 values in a matrix
Use for loop HR = numData(31:30:end,3); meanHR = HR*0; for i = 1:length(HR) i1 = (-5:-1)+i*30; % (25:30) ...

7 years ago | 0

| accepted

Answered
Trajectory animation using coordinate points
Animation it is just changing of images like in cartoons plot(x,y,z) hold on for i = 1:length(x) h = plot(x(i),y(i),z(i)...

7 years ago | 1

| accepted

Answered
Increase the interpolation increment
If you want to read every 5th point: i = 1:5:length(x); plot(x(i),y(i))

7 years ago | 1

| accepted

Answered
Fill regions of a vector around central point
Try this v = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1]; - 25 elements k = [5, 14, 21]; w = 2; k1 = repmat(-w:w,len...

7 years ago | 0

| accepted

Answered
Vectorizing nested for loops
Use pdist2() to calculate combinations of distances D = pdist2( ... ) cond = d <= (2*R + T); % indices of matrix you wa...

7 years ago | 1

Answered
Fitting curve : difficultu to do the modelized
I changed your time span % A = xlsread('data.xls','B2:E162'); % A = flipud(A); % flip up-down matrix rec1 = A(:,1)...

7 years ago | 0

| accepted

Answered
How to plot the intensity profile at 45 degree angle at certin coordinate?
Simple example clc,clear I = imread('image.png'); x = 900:1150; % x coordinate ( columns ) y = round( ta...

7 years ago | 0

| accepted

Answered
Line pathway using intersection points
Simple example n = 5; x1 = rand(n,2); y1 = rand(n,2); x2 = rand(n,2); y2 = rand(n,2); k = 0; % loop through all segme...

7 years ago | 0

| accepted

Answered
Height of one of the intersection of a line and a circle in MATLAB
Here is what i achieved Equation of a circle: Equation of a line:

7 years ago | 0

| accepted

Load more