Answered
XOR on rising edge of two arrays
A second approach: a = [0,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,1]; b = [0,0,0,1,1,0,0,1,1,1,0,0,1,1,1,1,0,1,1,1]; want =...

6 years ago | 1

Answered
XOR on rising edge of two arrays
With: https://www.mathworks.com/matlabcentral/fileexchange/41813-runlength a = [0,1,1,1,1,0,0,0,1,1,1,0,0,0,0,0,1]; b = [0,0,0...

6 years ago | 1

Answered
cell array into char
As fas as I understand, you should create a cell array. Then do this: cellarrayN = cell(1, N); Maybe this cell should contain ...

6 years ago | 0

Answered
Solving Newton Raphson Method
This is the expected behavior: while i<4 disp('Ea = '); i = i + 1; fprintf('iteration number = %d.\n', i); end This...

6 years ago | 1

Answered
What is the Fastest manner to match rows of 2 matrices?
Another approach is a C-mex function with a dull linear search: // MatchColumns.c // // Tested: Matlab 2018b, MSVC 2017 // ...

6 years ago | 1

Answered
Which method to use, basic for loop or loop through values of a vector
x = rand(1, 1e6); y = zeros(size(x)); ind = randperm(numel(x)); tic for loop = 1:10 for k = 1:numel(ind) y(ind(k...

6 years ago | 1

| accepted

Answered
What is the Fastest manner to match rows of 2 matrices?
Yes, for some sizes this can be accelerated usings cheaper hash values. Use https://www.mathworks.com/matlabcentral/fileexchang...

6 years ago | 2

| accepted

Answered
extract out values out of loop
% Pre-allocation of the output: len = length(Hi); XYZ = zeros(3, len); H = zeros(1, len); D = zeros(1, len); I = zero...

6 years ago | 1

Answered
How do I reduce the running time of this program
The profiler shows, that almost the complete time is spent in this line: if max(abs(f_n - f) / f_n) < epsilon Are you sure...

6 years ago | 0

Answered
Error while evaluating TimerFcn for timer Cannot create variable in workspace
What happens, if you set the TimerFcn to: 'TimerFcn', @(TimerH, EventData) sim('File.slx', 100000)

6 years ago | 0

Answered
Using structures as enum input to a function in MATLAB
You have defined a struct, but this is not an enum. With your code (if you omit the curly braces), you could use: choose(color...

6 years ago | 1

Answered
Multiplication of large matrices
A short tes: x = rand(2240, 94340); % 1.6 GB RAM tic y1 = x * x'; toc tic xt = x'; y2 = x * xt; toc On my i5 mobi...

6 years ago | 0

Answered
changing my mathworks.com location
Scroll to the bottom of this page. There is a rectangle with rounded corners (what is the english word for this shape?) includin...

6 years ago | 1

Answered
how to solve Index exceeds the number of array elements (1)?
Maybe you mean: g = gx(x0); % ^

6 years ago | 1

| accepted

Answered
Iterating over a vector to create a cell array without for loop
Most likely this cannot be vectorized. By why do you ask for it? Do you want to accelerate the code? This is possible: Avoid re...

6 years ago | 1

| accepted

Answered
How can I convert data of 2 cells into one vector?
Do not use the names of the built-in functions "min" and "max" as names of variables, because this causes troubles frequently. ...

6 years ago | 0

Answered
how to rename fields in struc and adding new field name
Adding a field at the end is trivial: porositiy.newField = []; Adding a field at a specific location is a bad idea, because th...

6 years ago | 0

Answered
For loops for functions that create structure arrays.
Remember, that size() replies a vector, e.g. [1 x 10]. Then for j = 1:size(V) means 1:[1, 10], but the colon operator uses...

6 years ago | 0

Answered
MATLAB interrupting the algorithm by timer
The timer runs in its own thread. The execution of the timer callback is correctly stopped by the error command, but not the reg...

6 years ago | 1

Answered
Are there any other methods to pass value into a predefined function of matlab . (Fmincon problem- passing extra parameters)
function [c,ceq] = confun(z,L,Lb,Ub) ... end Now create an anonymous function to provide the parameters: L = ... Lb = ... ...

6 years ago | 1

| accepted

Answered
Why the function mean does not return only one plot rather than 31?
mean(E, 24) calculates the mean over the 24th dimension. Remember that in Matlab all arrays are assume to have and arbitrary num...

6 years ago | 0

| accepted

Answered
How to automate running the same scripts in multiple folders
Do not use scripts, but functions for reliable code. The workspaces of the scripts influence eachother and you see, that you nee...

6 years ago | 2

Answered
Hyper nested for loops
Instead of nesting loop, use one loop and a vector of indices: n = 6; % n loops m = 5; % L...

6 years ago | 0

Answered
Searching for closely related filenames in a directory
['32_Y_32_Z_32_Omega_260.567_no_fields_',num2str(opts.no_fields),'and_25_sensors.mat'] Searching such files is complicated, bec...

6 years ago | 0

Answered
Creating a non-square diagonal matrix
s1 = 94037; s2 = 2240; v = rand(1, s2); % Test data M = zeros(s1, s2); M(1:s1+1:s1*s2) = v; % Linear indexing Or if ...

6 years ago | 0

Answered
Does ode15s call BLAS functions?
Matlab calls BLAS functions internally for matrix operations. ODE15 does not do this explicitely.

6 years ago | 0

Answered
Is it possible to have two indices in a for loop?
iList = [3 5 7 9 11 12 14 15 16 17]; for = 1:length(pathwayEMG_HR) i = iList(k); ... end By the wy: Move this expen...

6 years ago | 0

Answered
Running external commands without going through a shell?
You can try a mex routine: https://www.mathworks.com/matlabcentral/fileexchange/341-spawn Maybe this works for you: runtime = ...

6 years ago | 1

| accepted

Answered
One/zero Matrix, merge subset of columns
x0 = [ 0, 0, 0, 1, 0, 0; ... 0, 1, 1, 1, 1, 1; ... 0, 1, 1, 0, 1, 1; ... 0, 0, 0, 0, 0, 0; ... 0, 0, 0, 0, 0, 0; ... ...

6 years ago | 0

| accepted

Answered
Input [Hex] String then convert to binary from Hex
I guess, you are using an older version of Matlab, which does not allow to write hex numbers in the code directly. Then: HexArr...

6 years ago | 0

Load more