Community Profile

# Alex Mcaulley

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

View details...

Contributions in
View by

I get the following error "Dimensions of arrays being concatenated are not consistent."
Are you defining row vectors? Use ... in each line w20=[2.22939364554e-13,4.39934099226e-10,1.08606937077e-7,... 7.8025564785e...

1 day ago | 0

| accepted

Index exceeds array elements
The problem is in this line (you are changing the size of the array inside the loop): guess_vector(j) = [] One option could be...

1 day ago | 0

How do I record the entire row of a matrix if it has a peak value in the third column?
Try this: [~,locs] = findpeaks(xyK(:,3)); sol = xyK(locs,:);

2 days ago | 0

| accepted

repeating a sequence of code
Do you mean this? n = 1; while n ~= 3 disp(' Choose an Option Below '); disp(' 1 Convert Decimal Number to Binary ...

2 days ago | 0

| accepted

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

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

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

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

7 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

7 days ago | 0

| accepted

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

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

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

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

8 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

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

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

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

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

28 days ago | 0

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

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

1 month 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

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

3 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