Answered
How do i plot equal size of circle in square(100*100 m^2) without overlapping?
This is an extremly challeging task. See https://en.wikipedia.org/wiki/Circle_packing https://en.wikipedia.org/wiki/Circle_pac...

5 years ago | 1

Answered
cannot calculate mean on for loop
The elements of neg_m are overwritten repeatedly in the inner loop. Maybe you want: for ni = 1:35 neg_m(ni, :) = mean(resh...

5 years ago | 0

Answered
How to make the negative sign in the legend easier to see?
strcat removes interior spaces. This is not useful here and it is not in general. I consider this as a design error. Use cat in...

5 years ago | 0

| accepted

Answered
Index exceeds the number of array elements (1)
Replace for j = 1:n-1 by for j = 1:i-1 By the way, you can write s = 0; for j = 1:i - 1 s = s + U(i, j) * x(j); ...

5 years ago | 1

| accepted

Answered
How can I create three different axis?
See e.g.: https://www.mathworks.com/matlabcentral/fileexchange/67349-plot-with-multiple-y-axes https://www.mathworks.com/matl...

5 years ago | 0

| accepted

Answered
How to shuffle two matrices in a consistent manner
I assume, X is a matrix and you want to shuffle the rows. Then: X = X(P, :); % ^

5 years ago | 1

| accepted

Answered
How to get rid of a loop that depends on its previous iterations
Start with calculating the average manually instead of the slower mean() function: % Timings: R2018b, Win10, i7 data0 = rand(1...

5 years ago | 0

| accepted

Answered
Solving problem with ODE45
In the loop you are calculating the integration from 0 to 2*t(i) with the initial value set to y2(i-1, :). But this is another i...

5 years ago | 0

| accepted

Answered
Check for equality in the contents of two arrays ignoring order
unique, setdiff, union and ismember call the function sort also internally. So % assert(isequal(sort(A), sort(B))) Is a very e...

5 years ago | 0

Answered
How to identify duplicate values in an n dimensional array , then club the linked values related to it in another array
A = [ 1 8 10 4; ... 1 8 4 0]; T = isMultiple(A); B = A(T) % ? or what do you want? A(T) = 0; functi...

5 years ago | 0

Answered
Iteration Involving 1x4 matrix
while abs(P - Pgiven) > 1e-6 ... end

5 years ago | 0

| accepted

Answered
Conversion to double from function_handle is not possible.
objective = zeros(1,3); % Here objective is a double for i = 1:Nc % And here you want to store a function handle in the d...

5 years ago | 1

Answered
Issues running a Mex Function (.mexw64)
The leading "./" means, that it is searching in the current folder. Assuming, that the current folder is chosen as expected, is ...

5 years ago | 0

Answered
Why doesn't my function for writing a file work?
"Not enough input arguments" might mean, that you call this function without inputs. Therefore the most important part of the co...

5 years ago | 0

| accepted

Answered
Too many for loops, how to approach rearranging arrays problem differently?
Pre-allocate the output and avoid repeated calculations: a = 1:50; b = 10:50; tic aa = f2(a); bb = f2(b); for i = 1:le...

5 years ago | 0

| accepted

Answered
I didn't know how to find r
a = 6 * 18 * 18 a = 4 * pi * r.^2 r = sqrt(6 * 18 * 18 / (4 * pi))

5 years ago | 0

Answered
Estimate the Value of Pi
Your code runs fine and it is clean. It can be simplified, but the application of the index a is valid. I'm not sure why your te...

5 years ago | 0

| accepted

Answered
Dot indexing is not supported for variables of this type - ISSUE?
Start with experimenting: img2 = reshape(img, [4, 376, 672]); rgb = permute(img2([3 2 1], :, :), [2, 3, 1]); figure, image(r...

5 years ago | 0

| accepted

Answered
Remez exchange Algorithm for approximation
if a <= M < x(2) if v(end-1)< M <= b if i < M < i+1 These commands will not do, what you want. The comparison is evaluated fr...

5 years ago | 0

| accepted

Answered
Not enough Input arguments
Stephen hits the point: >>qardlecm This shows, that you call the function without input arguments. Perhaps you start it by cli...

5 years ago | 1

Answered
My "plot" has some problems
Did you update the graphic drivers and install all updates of Matlab? Try different graphic modes: opengl software opengl har...

5 years ago | 0

| accepted

Answered
Need matrix or vector with 1,0,1,0,1,0.........
Do you now the colon operator already? a = 2; b = 15; a:b a:3:b You can use this to create an index of the values, you want...

5 years ago | 0

Answered
Maximizing along n-1 dimensions of an n-dimensional array without a for loop
VV = rand(8, 9, 10); for ii = 1:size(VV,1) Vtemp = squeeze(VV(ii, :, :)); [V(ii), I(ii)] = max(Vtemp(:)); end ...

5 years ago | 0

| accepted

Answered
convert BGRA8 image format to RGB format
Do you have the pixels values as UINT8 array already? Then: RGB = BGRA8(:, :, [3, 2, 1])

5 years ago | 1

| accepted

Answered
A function that counts the number of zeros in a vector
Beside sum(D == 0) nnz(D) This would be working also, if the elements are 0 or 1 only: numel(D) - sum(D)

5 years ago | 0

Answered
matrix array for loop
See the command: size() https://www.mathworks.com/help/matlab/ref/size.html By the way, you find such commands, when you know ...

5 years ago | 0

Answered
Reading visual basic code language like matlab?
There is no direct translation from Visual Basic code to Matlab code. The solution is to learn a programming language, if you wa...

5 years ago | 0

Answered
Does Matlab initialize random seed at each -batch run?
Yes, exactly as you observe the random number generator is initialized with the same seed. Use rng to get different seeds. See:...

5 years ago | 0

Answered
How to maximize the graph area in case of subplots ?
There is a bunch of solution in the FileExchange. Search for "subplot": https://www.mathworks.com/matlabcentral/fileexchange?q=...

5 years ago | 0

Answered
Equivalent of numpy.where() value choice parameters
Your code looks almost fine: x = 0:9 y = (0:9) * -0.1 z = zeros(size(x)); z(mod(x, 2) == 0) = x(mod(x,2) == 0); % ...

5 years ago | 0

| accepted

Load more