Answered
How to add two cells with strings together?
The message tells you, that A and B have different number of elements. Then a concatenation cannot work. If both have the same s...

5 years ago | 1

Answered
How to reduce distance between two point of this curve ?
The trivial solution would be to reduce the numer of points: % th = linspace(pi/2, -pi/2, 100); ==> th = linspace(pi/2, -pi/2...

5 years ago | 0

| accepted

Answered
Degree to radians conversion
Import the Excelfile by readtable . The conversion from degree to radians is easy, but in most cases not needed, because all tr...

5 years ago | 0

Answered
Basic question about pointer in mex function
Q1. But I was wondering if z, y stores addresses not values how can we calculate like this z[i] = x * y[i]; ? This is a questio...

5 years ago | 0

| accepted

Answered
Compare rows of a column vector
The screenshot show the contents of ex_vec. It does not matter how you have obtained it. All you want to know is how to find row...

5 years ago | 0

Answered
Make a for loop for the following code
Naming a variable "went_from_to_probAge27" hides important information in the name. There this information can be accessed by re...

5 years ago | 0

| accepted

Answered
removing for loop by using 3d matrix
What is your purpose of vectorizing the code? The processing time is dominated by imagesc and pause here. I assume the loop are ...

5 years ago | 0

Answered
Why do I get a different result of calculation in for loop than in command line
Your analysis is correct: it seems unlogical. For an experiences programmer this is a secure signal, that something happens, whi...

5 years ago | 1

Answered
Massive matrix, tridiagonal, ones()
A = [2 13 0 0 0 0; 1 2 13 0 0 0; 0 1 2 13 0 0; 0 0 1 2 13 0; 0 0 0 1 2 13]; d1 = diag(A, 0) % [2 2 ...

5 years ago | 1

Answered
Problem with multiple inputs
for i=1:nargin nargin is the number of all inputs. For Untitled(a,varargin) thenumber of inputs is 1 larger than the size o...

5 years ago | 1

| accepted

Answered
How to get random samples with certain distance between them?
You have a [27889 x 2] matrix containing values from 0 to 5. There are only 36 different possibilities of taking 2 out of 6 elem...

5 years ago | 1

| accepted

Answered
Index in position 2 exceeds array bounds
Profile_Y_new(1,end+k) = Profile_Y_new(1,end+k-1) + (mean(diff(Profile_Y))); This line must fail, because Profile_Y_new(1,end) ...

5 years ago | 0

| accepted

Answered
MATLAB is incredibly slow, even immediately after opening
Is only Matlab affected or do other programs suffer from the same problem also? Did this problem exist since you have installed...

5 years ago | 0

Answered
average over a certain range of index ?
Another method assuming, that the intervals are dense and not overlapping: A = [1 7 12 20 23 31]; B = [6 11 19 22 30 35]; % A...

5 years ago | 0

Answered
average over a certain range of index ?
nC = 1e6; % Number of elements of C nA = 1e5; % Number of intervals C = rand(1, nC); % Test data ...

5 years ago | 0

Answered
How to plot vectors within in a for loop using a variable?
See: TUTORIAL: EVAL Using variables called x1, x2, ... hides an index in the names. Don't do this, because it is a shot in your...

5 years ago | 0

Answered
Tips on generating a subset of linspace(0,1,k)^n for "large" n and k.
See: FEX: VChooseKR (C-Mex) : k = 14; n = 12; % <= k A = linspace(0, 1, k); P = VChooseKR(uint8(k:-1:1), n); B = A(P); % ...

5 years ago | 0

| accepted

Answered
Thresholding based on smaller domains
Two solution: X = randi([0,10], 12, 12); % arbitrary test data n = 10; % Neighborhood Y = conv2(x, ones(n, n) / (n * n), 's...

5 years ago | 0

Answered
how to divide matrix using mat2cell
Are you sure you need a cell array? If the chunks have the same size a numerical array is much more efficient: A = rand(1, 2199...

5 years ago | 0

| accepted

Answered
How to treat with the error "Undefined function or variable 'M'." where M is mentioned in a Matlab ode function, and it's also a function of defined variables in the Matalb code?
Each function has its own worksapce, whereby "workspace" means the set of locally known variables. If you want to access a value...

5 years ago | 1

| accepted

Answered
Getting Error while using "im2gray" function. I'm using Matlab 2020.
Which Matlab version are you using? In the documentation: https://www.mathworks.com/help/matlab/ref/im2gray.html you find: I...

5 years ago | 0

| accepted

Answered
Delete rows of a matrix based on specific column threshold values?
A = [ 1 2 1 2 3 2 1 1 2 3 4 3 1 4 2 4 3 2 5 2 5 2 3 4 3 2 4 6 4 3 2 4 2 4 2] index = A(:, 7) ...

5 years ago | 0

| accepted

Answered
Create new matrix based on grid location
A = [4 1 0.6; 4 1 0.8; 1 4 0.5; 1 3 0.3; 3 2 0.1; 2 1 0.6; ... 2 4 0.5; 3 2 0.4; 1 1 0.3; 1 2 0.1]; result = zeros(max(...

5 years ago | 0

| accepted

Answered
Need help to create a function for a roulette simulation?
"If the ball lands on the field which the user choose" How does thze user choose a field? By the input n? This input is overwri...

5 years ago | 0

| accepted

Answered
Intersection of two matrices- intersect function not working as intended
With some guesses: L1S_T = readtable('L1S.xlsx','ReadVariableNames', 0); L1S = L1S_T.Variables; L1S = L1S(:, 1:3); L2S_T =...

6 years ago | 0

| accepted

Answered
In a vector, how to remove neighbours too close from one another
I assume a C-mex function is the best solution: // File: MovThresh.c // Compile: mex -O MoveThresh.c #include "mex.h" ...

6 years ago | 0

| accepted

Answered
Is there a way to define a default axis position, similar to defaultFigurePosition?
Yes. % A strange small size to be sure, that it works: set(groot, 'defaultAxesPosition', [0.25, 0.25, 0.2, 0.2]) figure; p...

6 years ago | 0

| accepted

Answered
Is there a faster way to cube a array?
On my i5, Matlab R2018b: tic; y = x.^3; toc % Elapsed time is 0.109015 seconds. tic; y = x.*x.*x; toc % Elapsed time is 0....

6 years ago | 0

| accepted

Answered
for loop with vectors having different sizes
Omit the single quotes, because there is no reason for the conjugate complex transposition: a=[1 2]; b=[3 4 5]; c=[6 7]; d=[...

6 years ago | 0

Answered
Manual Runge-Kutta for system of two ODEs.
The diagram looks, yoike you are integrating: @(t, y) [-y(1)+6*y(2); -y(2)+4*y(1)] This code produces an equivalent output: t...

6 years ago | 2

Load more