Community Profile

photo

Alex Mcaulley


Last seen: Today
270 total contributions since 2019

Alex Mcaulley's Badges

  • 6 Month Streak
  • Knowledgeable Level 4
  • Pro
  • Revival Level 1
  • Solver
  • First Answer

View details...

Contributions in
View by

Answered
More efficient "for i in array" loops
Using your equations directly: x = [1 2 3 4 5 6]; c = 1; cos_theta = (1-((2*x)/c)); theta = acos(cos_theta);

3 days ago | 0

Answered
My code won't run. It says there is an error in line 30.
There is an error in your calls to matlabFunction: function [] = Newton(f, x1, tol, N) % % Newton uses Newton’s method to app...

3 days ago | 0

Answered
How to remove multiple elements in a row matrix
This is a very basic problem. I recommend you to do the Matlab tutorial Being A your array: A = A(2835:end);

3 days ago | 0

Answered
Converting matirx into vektor inside a cell array
Try with this: for i=1:n for j=1:m ev1{j,i} = V{j,i}(:,1); ev2{j,i} = V{j,i}(:,2); end end

3 days ago | 0

| accepted

Answered
How to solve a matrix quadratic equation?
syms w solve(det(K-w^2*M),w)

3 days ago | 0

Answered
campare a row value with the next row
Another option: a = [1;1;0;0;0;1;0;1;0;1]; b = diff(a); b(~b) = 2*a(~b); sol = splitapply(@numel,b,b+2) %Ordered as [1,0],...

3 days ago | 1

Answered
Solve a quadratic equation
To use the function roots you need to reformulate your equation: tau = 0.1 f4 = [3; 2; 6; 8] f8 = [2; 6; 7; 3] eq = @(f4,f...

4 days ago | 0

| accepted

Answered
Error: Attempt to execute SCRIPT mesh as a function
Because your live script has the same name than the function mesh and when you call this function, in fact you are calling your ...

4 days ago | 0

| accepted

Answered
Index exceeds the number of array elements (1).
VarHigh is a constant and you are using it as an array... VarHigh(2) %Throws an error

5 days ago | 0

Answered
How would I write this code without using loops?
Another option: N = 1000; five = 2*5:5:N; seven = 2*7:7:N; res = setxor(five,seven)

19 days ago | 0

Answered
Hold on Not showing all of my plots on one graph
Take a look at the variables you are plotting, they are duplicated. I mean Bsigmay is equal to sigmay, Bsigmaz is equal to sigma...

19 days ago | 0

| accepted

Answered
How do I use a vector as a set of indices?
Try this: m = 5000; num_labels = 10; y = randi(num_labels,m,1); yrec = zeros(num_labels,m); yrec(sub2ind(size(yrec),y',1:...

20 days ago | 0

| accepted

Answered
Problems using solve function for linear system of equations
Use assume function before solve: assume(0 < p1 < 270) assume(0 < p2 < 270) assume(0 < p3 < 270)

24 days ago | 0

Answered
Command to delete last row and column of a matrix
A(:,end) = []; %Delete last column A(end,:) = []; %Delete last row

27 days ago | 0

| accepted

Answered
How would I locate non-zeros given a condition?
For example: A = [1 0 1 1 0 0 0 1 0 0 0 0]; rows = find(A(:,4) & sum(A(:,1:3)~=0,2));

27 days ago | 1

Answered
How to make statements intersect
a=[0 1 2]; b=[1 1 3]; if all(a==b) fprintf ('yes') else fprintf ('no') end

1 month ago | 1

| accepted

Answered
how to find size of scale bar on image
One approach would be: First, you need to segment the scale bar using any segmentation function, for example imbinarize (using ...

1 month ago | 0

Answered
Find the diameter of the parts in an image processing?
One approach would be: First, you need to segment the objects you want using any segmentation function, for example imbinarize,...

1 month ago | 0

Answered
How to select the columns of a matrix which are a multiple of 5?
N = M(3,5:5:end)

2 months ago | 0

Answered
Adding to the first value in a matrix based on the second value in that row.
Being A your matrix: A(A(:,2) == 11 | A(:,2) == 12,1) = A(A(:,2) == 11 | A(:,2) == 12,1) + 1

2 months ago | 0

| accepted

Answered
Creating an array from 1 to n
n = 10 % 1:n ans = 1 2 3 4 5 6 7 8 9 10

2 months ago | 1

| accepted

Answered
How can I create n arrays of size 100 each with random integer values?
c = cell(1,100) for i = 1:100 c{i} = randi(100,1,100) end

2 months ago | 1

| accepted

Answered
Smoothing jumps when using unwrap()
You need to have a jump higher than pi to avoid the small jumps using unwrap (and this is not you case). Then, a trick you can d...

2 months ago | 0

| accepted

Answered
How to separate a variable out of trigonomic expression
It is not a Matlab question, but you can do: cos(a+b)/sin(a+b) = 1/tg(a+b) = (1-tg(a)*tg(b))/(tg(a)+tg(b))

2 months ago | 1

Answered
How to run a loop with different values and plot the result?
Yo can do it with an external loop with dt: for dt = 1:10 x=5; x_arr=[]; x_arr(1)=x; for i=1:10/dt ...

2 months ago | 1

| accepted

Answered
Integration fo function A(c) from -inf to +inf
A = @(c) sqrt(m/(2*pi*k*T1))*exp(-m/(2*k*T1)*(c-c_bar1)^2) q = integral(A,-inf,inf)

4 months ago | 0

| accepted

Answered
how do I append to an array within a loop with float values?
Try with this: k = 0:0.1:20; solutions = zeros(size(k)); for ii = 1:numel(k) a = -k(ii); b = -k(ii); soln= ...

4 months ago | 0

Answered
Is it another command using to compare between vector and cell?
Then, to obtain the elements of U that doesn't exist in S, you can do: U = [1,2,3]; S = {1,2}; w = U(~ismember(U,cell2mat(S))...

4 months ago | 0

| accepted

Answered
How do I store the changing values of a variable (generated in a for loop) into a single file without overwriting the previous one?
n = 100; areatriangle = zeros(1,n) for ii = 1 : n areatriangle(ii) = .5*((ii/2)*ii); end or: areatriangle = .5/2*(1:n)...

4 months ago | 0

| accepted

Answered
How to find the position of points in a coordinate system?
Using for loops: R = zeros(numel(X),numel(Z)); for i = X for j = Z R(i,j) = sqrt(i.^2+j.^2); end end

4 months ago | 2

| accepted

Load more