Community Profile

# Alex Mcaulley

##### Last seen: Today
271 total contributions since 2019

View details...

Contributions in
View by

creating array with entries as numbers
Do you mean this? n = 1.44:0.001:1.45;

8 hours ago | 0

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

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...

4 days ago | 0

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);

4 days ago | 0

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

4 days ago | 0

| accepted

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

4 days ago | 0

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],...

4 days ago | 1

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

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 ...

5 days ago | 0

| accepted

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

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

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...

20 days ago | 0

| accepted

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:...

21 days ago | 0

| accepted

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)

25 days ago | 0

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

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

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

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 ...

2 months ago | 0

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,...

2 months ago | 0

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

2 months ago | 0

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

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

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

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

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))

3 months ago | 1

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 ...

3 months ago | 1

| accepted

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

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

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