K_UL and Kcel are matrices.
M1=4;
M2=4;
nK = size(K_UL,2);
Us=zeros(ndof,nK);
for x=-M1:1:0
for y=-M2:1:M2-1
fx=1i*pi*x/M1;
fy=1i*pi*y/M2;
u=Myfun(Kcel,M1,M2,fx,fy);
Us = Us+(1+(x>-M1&x
Thanks for your suggestion Harald Kirchsteiger
But, here I am using a function Myfun inside the loop. Which depends on a matrix (Kcell). Can we use such type of predefine function inside the parallel loop?
I would start from vectorizing your code, vectorization often works better than parfor
https://stackoverflow.com/questions/14035365/why-does-vectorized-code-run-faster-than-for-loops-in-matlab
The vector version (needs testing) is as follows:
fx=1i*pi*[-M1:1:0]/M1;
fy=1i*pi*[-M2:1:M2-1]/M2;
calculate values of
1+(x>-M1&x
As a primer for the further work please consider the following code prepared for testing of a single element from your loop:
tic
end
toc
time_loop=toc
time_vec=toc
speedup=time_loop/time_vec
The speedup is of the order of
5 for M1=4, M2=4
260 for M1=1000, M2=500
19300 for M1=10000, M2=5000
Hi, I have problems with running gel electrophoresis. I have tried agarose gel electrophoresis and native PAGE. I have two proteins, which have molecular weights of ~30kDa and ~180kDa and two...
03 March 2021 4,275 4 View
Hi, im trying to make a projection in a 3d comsol model. I have a non uniforme chanel and my intention is to get the average tempreture in the y-z cross section and se the average tempreture...
02 March 2021 4,624 4 View
Which solution reveals the microstructure and features of nickel-based alloys?
02 March 2021 2,221 3 View
Which tools can be used to generate machine codes for additive manufacturing?
02 March 2021 7,220 2 View
I am searching for a good place for the Post Doc,
02 March 2021 4,053 3 View
Working on chandrayaan-2 DFSAR data, there are three datasets available: 1) Slant range image data product: The slant range complex image file. Each pixel is represented by two 4-byte floating...
02 March 2021 8,481 3 View
Hello, The Cranet website does not provide any lead to the data obtained from their multinational survey on HRM practices. Any help on accessing the data would be most appreciated. Thank...
01 March 2021 9,536 3 View
I am going to have a expression cloning of mammalian gene by using shuttle plasmid to transforming the E.coli However I don't know I should only inserting the Coding sequence ,or I can...
28 February 2021 5,440 3 View
Is there any book chapter/book, webpage or research article available to understand genome-wide gene identification?
28 February 2021 8,095 1 View
Hi every body I need to collect datasets from different source to work on recommendation system algorithms, could you advise me how collect data?
27 February 2021 7,063 7 View
How do I do energy minimization in lammps with NVT ensemble ? I am using the following command and it does not seem to work. It stops at extremely high energy and gives me the error zero search...
01 March 2021 2,294 3 View
Dear Researchers I am trying to perform a PIL simulation using STM32F4 Discovery board and comunication serial USB TO TTL. During simulation I receive the following timeout error: An error...
01 March 2021 2,327 1 View
Let F be a field. Consider U, the set of n times n strictly upper triangular matrices in F. For X, Y in U, we call them similar if there exists some S, which is non-degenerate and upper...
01 March 2021 2,957 8 View
When explaining substitution models, the substitutions are expressed as Q matrix. Why is the sum of the elements in a row zero?
28 February 2021 3,864 3 View
Hello, I have simulated a single battery cell using Thevenin equivalent circuit. For a battery pack, I have a large number of cells connected in series and parallel connections. Is there any way...
28 February 2021 2,116 1 View
The following code (see 1st 2 images attached) is used to produce PID controller values that are designed to control the system (G). The code finds the PID controller values (noted as k) by using...
28 February 2021 6,560 14 View
I have input and output data set for "ANFIS modeling in MATLAB", and I am getting some negative predicted values of output in testing. However, the predicted values of output in training are...
28 February 2021 3,459 3 View
I am required to learn about Flyback converters and I got stuck not knowing to full design of the power supply flyback converter Based USB Charger Model using Simulink, especially the design model...
25 February 2021 5,435 2 View
I do need the Matlab code of Fractal Discrete Cosine Transform (FDCT). Can anyone who has already implement this code, help me with the implementation of this transform?
24 February 2021 5,602 2 View
Hi Hope you are well. Can you please share your code for D2D implementation in Matlab. I want to implement D2D in Matlab based Vienna simulator and struggling to deploy D2D. Thanks
24 February 2021 9,378 3 View