Answered
Finding the previous consecutive entries in a matrix column
AS far as I understand the discussion, this solves your needs: B = max(cumsum(A, 1) - 1, 0);

4 years ago | 1

Answered
How to replace repeating values for each column by NaN?
A = [1 2 3 4; ... 2 3 4 4; ... 3 1 3 1; ... 3 1 3 2]; M = [false(1, wi...

4 years ago | 0

| accepted

Answered
How do I create this full diagonal matrix
This is a Toeplitz matrix. See: doc toeplitz

4 years ago | 2

Answered
Unable to re-install R2021b after updating it (Java exception).
Ignoring the update messages is a really bad idea. If you are afraid of bugs during the updates, create a backup of your compute...

4 years ago | 1

Answered
Calculating power in a loop has different result from the matlab power function
Neither the power operator nor the loop produce the exact result: x = sym(13); x^15 fprintf('%.0f\n', 13^15) y = 13; for k ...

4 years ago | 1

| accepted

Answered
Comparing implicit methods - Euler implicit, Crank Nicolson, three-time level
A bold guess: phi = zeros(n_points+1); phi(1)=3; phi(n_points) = 1; This creates phi as square matrix. I'd assume you want a...

4 years ago | 0

Answered
How to export a table including column names?
Maybe there is a typo in the original code? If I adjust the variable names, which must be legal Matlab symbols in my R2018b vers...

4 years ago | 0

| accepted

Answered
How to numerically solve and plot after solving the integration with a constant Multiplication
B = 51; C = 10; S0 = 17.34; % ??? lam_d = 19.34; % ??? H1 = (S0/lam_d)^2 / pi; K = @(t, y) (sqrt(sin(t) - t * cos(t...

4 years ago | 0

| accepted

Answered
i was trying to run three different mat files some reason only the first one is read by matlab
It is a frequent cause of unexpected behavior, that MAT files contain other variables that the user assumes. Therefore it is rec...

4 years ago | 0

Answered
How to read a txt file with 2 comma separated values into an array?
data = fileread('resultat.data'); value = strsplit(data, ',');

4 years ago | 0

| accepted

Answered
Quasi-euclidean distance metric in 3D
As the documentation reveals, that it handles 2D matrices only: https://www.mathworks.com/help/images/ref/bwdistgeodesic.html . ...

4 years ago | 0

Answered
Index exceeds the number of array elements (11819)
You run the loops over 11903. The data have 11819 elments only. Most likely you want to replace for n=1:11903 by num = numel...

4 years ago | 0

Answered
compare the column 2 of two matrix and forming the matrix with same entries in column 2 of Second Matrix.
A1 = [115.28 30 1; ... 115.26 33 2; ... 115.25 8 3; ... 115.24 21 2; ... 115.24 25 1; ... 115.21 2 2; ....

4 years ago | 0

| accepted

Answered
Write a recursive function called fibor
If it is really the problem, that you use two functions, simply join then to one function: function out = fibor(n, a, b) if na...

4 years ago | 1

| accepted

Answered
Mandelbrot set escape value is complex?
Here a cleaned version of your code: Calculating norm() twice is a waste of time. abs() is faster than norm(). No need to cr...

4 years ago | 1

| accepted

Answered
Total lines of code of MATLAB product
The question is too vague to be answered. Do you mean the core Matlab or inclusive all toolboxes? Many toolbox functions call th...

4 years ago | 1

Answered
How do you sum concatenated variables in a system of ODES with a For Loop?
This is trivial, if you do not create a bunch of variables, but an array: K(1) = 0; K(2) = C(1) * A + B; K(3) = C...

4 years ago | 0

Answered
How to write my function output in various form?
This works automatically with any function. The ~ simply ignores the replied value in the caller. You do not have to consider th...

4 years ago | 0

Answered
Why it keeps show the error incorrect use of '=' operator?
If you run a Matlab version before R2021a, use: pnl = uipanel(fig, 'Position', [0 0 1 1], ... 'Title', "Ur...

4 years ago | 0

| accepted

Answered
How do I find the first of the shortest words in a sentence?
You are on the right track. len = strlength(s0); % Better then "l" to avoid confusion with "1" min(len) This replies the mi...

4 years ago | 1

Answered
Would I be able to download an older version of MATLAB if I were to purchase a license?
Yes. If you buy the license of a current version, you can download and activate older versions in addition.

4 years ago | 0

| accepted

Answered
Fast Euclidean Distance Calculation
There is no reason to call bsxfun, if the arrays have the same sizes: % d = sqrt(bsxfun(@plus, sum(X .* X, 2), ... % ...

4 years ago | 0

| accepted

Answered
A bit of MATLAB syntax fun
No, I cannot guess it. I'm even astonished, that copy&pasting ">> x = 7;" works inspite of the ">>". Is this documented? By th...

4 years ago | 0

Answered
Speeding up to find minimum value using min() function
c = c(:); % Make it a column vector to be sure nc = numel(c); bin = [c(1); (c(1:nc-1) + c(2:nc)) * 0.5; c(...

4 years ago | 0

Answered
Impossible to print *really* vector plots when containing a lot of data
Yes, your oberservation is correct. If the 'RendererMode' of the figure is set to 'auto', Matlab enables the OpenGL renderer if ...

4 years ago | 0

| accepted

Answered
Is there any way to display a progress bar in command window while the code is running?
Yes. You find several dozens of progressbars and waitbars for figures, dialogs, the command window and the statusbar in the File...

4 years ago | 0

| accepted

Answered
How to calculate a triple sum with a dependent index using Matlab?
What is the intention of: if n==0 || N This conditio is TRUE, if n is zero or N is not zero. I assume you want: if n==0 |...

4 years ago | 1

Answered
Problem with plotting dots in points
The loop does not depend on the loop counter: i = 8; % <- this is the index in all iterations for c = 1:8 I assume you mean:...

4 years ago | 0

Answered
Convert portion of matrix under the diagonal to column vector
A = [ 1 2 3 4 5; ... 2 1 2 3 4; ... 3 4 1 2 5; ... 0 3 2 1 2; ... % 0 inserted 5 4 3 2 1]; s = ...

4 years ago | 1

Answered
All combinations of cell arrays
A = [1 2 3; ... 1 2 4 ; ... 1 3 5]; B = [1 6; ... 4 5]; C = [repelem(A, size(B, 1), 1), ... repmat(B...

4 years ago | 0

Load more