Answered
How can I copy one row to the another row?
A = [5 6 7 8 9 0 1 2 3 4; 5 6 7 8 9 0 1 2 3 4; 5 6 7 8 9 0 1 2 3 4; 5 6 7 8 9 0 1 2 3 4; 5 6 7 8 9 0 1 2...

5 years ago | 0

| accepted

Answered
Fast implementation of max-plus matrix multiplication
A C-mex version: [EDITED: Check of type double is added] // mp_prod_mex.c // C = mp_prod_mex(A, B) // INPUT: A, B: Real dou...

5 years ago | 3

| accepted

Answered
Selecting element at same position in a matrix
If you need the indices again, store them in variables: i1 = randi([1, size(VID1, 1)]); i2 = randi([1, size(VID1, 2)]); ID1...

5 years ago | 0

| accepted

Answered
Transform 3D binary matrix into 2D
Your code overwrites the output for each loop over i=1:lev. An equivalent code without a loop: %seg2 = seg1(:, :, end); What s...

5 years ago | 0

Answered
Rewrite Matlab ODE into Python - IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed
The error message tells, that res replied by simVirusSpreading() is a vector, but you try to access it as a matrix with 2 indice...

5 years ago | 0

Answered
Error using randi Size inputs must be scalar (Matlab)
"C is the random subset of B of size Ai" : for i = 1:n % Without repetitions: C = B(randperm(numel(B), A(i))); % O...

5 years ago | 0

| accepted

Answered
Force begin/end slope of trendline scatterplot
See: https://www.mathworks.com/matlabcentral/answers/94272-how-do-i-constrain-a-fitted-curve-through-specific-points-like-the-o...

5 years ago | 0

| accepted

Answered
How to take precalculated variables in a function, without defining the variables within said function?
You have defined the function down() with input arguments. Then use them: A = T/(0.5*R*V^2*AR); if(F~= 0); M = F/V; ...

5 years ago | 0

| accepted

Answered
Matlab doesn't open (it's installed and activated)
If you are running Matlab 2020b, the folder is not called "R2018a", but "R2020b". Insert this in the Windows Explorer's address ...

5 years ago | 0

Answered
Terminate while loop when user hits enter
Avoid repeating code: disp('Begin entering the data points') t = 0; while true % Infinite loop x_point = input('ente...

5 years ago | 1

| accepted

Answered
How to Open a Folder
Maybe you want to open a file inside this folder? function main myPath = fileparts(mfilename('fullpath')); % Folder of ...

5 years ago | 0

Answered
how to grab the last value in a loop?
In your first code: seno_m(i,1)= nanmean(sin(Date_wd_daily(B(i):B(i)-1,9))); % ^^^^ ^^^^^...

5 years ago | 0

| accepted

Answered
Human Neuromechanics, ERROR IN CODE
The failing part of the code: % Jacobian Jacobian = @(q) [-Length_S * sin(q(1,:,:)) - Length_E * sin(q(1,:,:) + q(2,:,:)), ......

5 years ago | 0

Answered
Matrix construction over a loop
Maybe you want: for i = 1:length(x) A(i) = a * b / x(i); B(i) = c + A(i) / b; D(i) = a + b; E(i) = 1 - 2 * c; .....

5 years ago | 0

Answered
Calculating standard deviation for each year
Do you want: vola2 = splitapply(@(x) std(x, 'omitnan'), stocks.RET, group);

5 years ago | 0

| accepted

Answered
How to stop MATLAB from opening every time I switch on my computer?
This is not a problem of Matlab, but a feature of the operating system. So this question is actually off-topic. Open the contro...

5 years ago | 1

Answered
Change keyboard shortcut for terminate code while running in Mac OS Matlab 2020
The shortcut for stopping the execution is controlled by the operating system. You cannot modify it from inside an application. ...

5 years ago | 0

Answered
Storing values in an array from function file called by ode15s solver
The code is very confusing. The relative tolerance of 5.421011e5 is extremely huge. Are you sure that this is meaningful in you...

5 years ago | 0

Answered
Calling C++ mex in loop crashes Matlab
There is a time delay between the check of !isWriting and setting isReading = 1. This is a racing condition. Use a thread-safe s...

5 years ago | 0

| accepted

Answered
Making script execution go faster
Avoid scripts but use functions. This can increase the speed substantially, but most of all the clarity and maintanability of th...

5 years ago | 0

| accepted

Answered
How to access alternate elements from a matrrix?
a = [0 4 5 6 7; ... 0 0 0 0 0] n = size(a, 2); for i = 1:n / 2 k = (i - 1) * 2...

5 years ago | 0

| accepted

Answered
Why am I getting the error, "Array indices must be positive integers or logical values."
What is "squeeze"? Did you shadow the function by defining it as variable? The left hand side of an assignment cannot be a func...

5 years ago | 0

| accepted

Answered
Extracting Data from Over 600 .nc Files...
See: FAQ: How to process a sequence of files Folder = 'C:\Your\Data\Folder'; FileList = dir(fullfile(Folder, '*.nc')); for iF...

5 years ago | 1

| accepted

Answered
How can I take the value from an equation and plug it back into the same equation? (Newton-Raphson)
Replace E = D - F(D)/F'(D) by D = D - F(D)/F'(D) For the 2nd part: You have defined the function with inputs: function [A...

5 years ago | 0

Answered
cant display my new image
imshow does not accept cell arrays as input. It needs a matrix. Either create this matrix directly: d = repmat(a, 30, 30); or...

5 years ago | 1

| accepted

Answered
Help me to optimize this code to perform better Image Processing
The command mean(X) is surprisingly much slower than sum(X)/numel(X). So replace: mean(mean(thisFrame(:, :, 1))) by sum(thisF...

5 years ago | 1

| accepted

Answered
Loop Through Files to Import
See FAQ: How to process a sequence of files "with the same name as the filename" - This is a bad idea. Prefer to use either the...

5 years ago | 0

| accepted

Answered
How to write a matrix to a .txt file without overwriting the text file in MATLAB 2019a?
You can write 11'000 files and joint them afterwards.

5 years ago | 0

Answered
how to load images in order
Folder = 'C:\Users\Nik\Desktop\NNDL-Pr1\English Alphabet'; for ii=1:26 SubFolder = sprintf('%d', ii); for jj=1:20 ...

5 years ago | 0

| accepted

Answered
how to understand .sc .mat in matlab
The command func_in.mat = ... creates the struct "func_in" with the field "mat". See: doc struct A web search is a good strate...

5 years ago | 0

Load more