Answered
how to make the same length in the struct
s=struct('a',rand(5,1),'b',rand(3,1),'c',rand(6,1)) maxheight = max(structfun(@height,s)); padarrays = structfun(@(x) [x; ze...

2 years ago | 2

Answered
Matrix and vector multiplication of size using a CPU is very slow. Using GPU is much quicker but I need a way around the size limitation.
"I thought, because I skim read (it's an age thing!) that gather transferred stuff from GPU to ordinary memory. I'm not convince...

2 years ago | 0

Answered
Counting zeros which are lying between nonzero elements by considering consecutive zeros as a single element in a matrix
A=[1 0 1 1 1 0 0 1;0 1 0 1 1 0 1 0;0 0 1 0 0 0 0 0;1 0 1 1 0 0 1 1] max(sum(diff(~~A,1,2)==1,2)-~A(:,1),0) % If A is binary ...

2 years ago | 0

Answered
generate array of Different random floating numbers in a specific range
" (1, 100) in MATLAB. randperm is creating integer, but I want float numbers , preferable with 1 decimal point. Like 20.1 , 34.2...

2 years ago | 0

Answered
Counting zeros which are lying between nonzero elements by considering consecutive zeros as a single element in a matrix
Always helpful the old for-loop A=[1 0 1 1 1 0 0 1;0 1 0 1 1 0 1 0;0 0 1 0 0 0 0 0;1 0 1 1 0 0 1 1] [m,n] = size(A); count ...

2 years ago | 0

Answered
Finding the first 1 in a binary set using optimization
You ask the same question several time. Without any other a priori knowledge, scan your array until 1 is meet. There is no mira...

2 years ago | 0

Answered
Counting zeros which are lying between nonzero elements by considering consecutive zeros as a single element in a matrix
A=[1 0 1 1 1 0 0 1;0 1 0 1 1 0 1 0;0 0 1 0 0 0 0 0;1 0 1 1 0 0 1 1] d=diff(A~=0,1,2); [~,i,v]=find(d'); vl=zeros(size(A,1),1)...

2 years ago | 0

Question


Slider (legacy) with no room to slide?
I would like to create a slider (legacy version) to select a whole number from 1 to a given n. For n >= 2 this is OK, the curso...

2 years ago | 1 answer | 0

1

answer

Question


What functions need GPU support
Recently there are few posts about function that are not fully support gpuArray and could benefit from more intensive GPU suppor...

2 years ago | 3 answers | 1

3

answers

Answered
Optimizing for speed. Moving skewness finder. Cumulative sum proving to be bottleneck.
Speed optimized code changes are: Vectorize for-loop Avoid padding 0 by treating the first "iteration" in separate code. Mutu...

2 years ago | 0

| accepted

Answered
Why does Matlab 2023a crash when running my code?
/home/matt/MATLAB-Drive/Lab/required_files/oms/supporting_files/code_thirdparty/TobiiPro.SDK.Matlab_1.6.2.36/lib/64/tobiiresearc...

2 years ago | 0

| accepted

Answered
Change zoom mouse cursor and mouse wheel zoom factor in R2019
My workwround solution % test zoom mouse scroll wheel accelerator close all plot(sin(linspace(1,10))) figh = gcf; % Do th...

2 years ago | 0

Answered
Matrix and vector multiplication of size using a CPU is very slow. Using GPU is much quicker but I need a way around the size limitation.
I run your (slighly modified) code with xRange = 100 (EDIT) and get the finite result My config: R2023a, Windows 11, Laptop 32 ...

2 years ago | 0

| accepted

Answered
Faster three dimensional higher order interpolation?
You probably need to change an existing open interpolation code to use efficiently gpu arrays. The cubic methode is smooth meth...

2 years ago | 0

Answered
Optimization of a script
The v you compute is simply 132*b*(c-1) You want to optimiza it? Take b=Inf and c=Inf

2 years ago | 1

| accepted

Answered
Efficient searching to find the first element of an array meeting a condition
just fo the obvious for loop for i = 1:length(x) if expensive_check_for_meet_condition(x(i)) ifind = i; ...

2 years ago | 2

Answered
Automatically set number of outputs of the gradient function
A = rand(10,10,10); % This works for any dimensions of A if isvector(A) % EDIT N = 1; else N = ndims(A); % 3 in t...

2 years ago | 1

| accepted

Question


How to check if an object is NaN
I want to check a generic object "is equal" to NaN. The command isnan(object) throws an error and the command isequal(object, N...

2 years ago | 1 answer | 0

1

answer

Answered
Why result of conv and point wise multiplication has different result?
You have at least 2 errors in your codes The convolution by for-loop needs to flip the kernel (Morlet) The MATLAB convolution ...

2 years ago | 0

| accepted

Answered
Runge-Kutta with a function that changes at each time step
Again everything is written in the doc of ode45 "For information on how to provide additional parameters to the function odefun,...

2 years ago | 0

Answered
Using Runge-Kutta in Matlab
" I can calculate an arbitrary velocity f(x,t) from the forces acting on a position x." Good this is a very good starting point...

2 years ago | 0

| accepted

Answered
Extract rows from a matrix considering continuous numbers in the first column
For multiple values of rmax (in a vector) matrix = ... [59 1 2 3 1899 % I invent it 60 210 96 92 398 62 33...

2 years ago | 0

| accepted

Answered
How can I implement these for loops efficiently using covolution?
Use conv x = (0:0.2:5).^2; L = 3; delta = rand; T = rand; % Your method xSinc = zeros(size(x)); for xx = 1:length(x) ...

2 years ago | 1

Answered
Plot multiple data sets fast - fastest/latest/efficient method up to R2023a
@Florian Berzsenyi Is is possible and viable to preallocate all lines first, and then call drawnow expose? Yes. Note the I pe...

2 years ago | 0

Answered
elements >0 are present in matrix only once
a= [3 5 9 12 0 0 0 0 4 6 7 8 10 11 0 0 15 17 18 19 ...

2 years ago | 0

| accepted

Answered
ismembertol second output specification
Here is my though on what index ismembertol returns. It is the first index that A belong after rearrange B by dictionary like s...

2 years ago | 0

Answered
Memory required for struct array
The function structbase_bytesize_fun that computes the "base" memory of the struct s is as following: fieldname_bytesize = name...

2 years ago | 0

Question


Memory required for struct array
In this answer https://www.mathworks.com/matlabcentral/answers/2010767-struct-function-in-matlab Walter Roberson gives some num...

2 years ago | 1 answer | 0

1

answer

Answered
The least square with changing number of lines of matrix
A = rand(24,6); % your full matrix b = rand(24,1); % your measurements % which data you want to remove? removeidx = [1 4 24...

2 years ago | 0

Answered
ismembertol second output specification
@Steven Lord "use the form at the bottom of the documentation page" Do you mean clicking on the rating with "stars"? If yes I j...

2 years ago | 1

Load more