Using the variable editor allows us to change as many values of the matrix as we want. Only the dimension is different between them, all variable are of type “Double”: Keep in mind that for Scilab there is no difference between a vector or a matrix. Or by inserting the elements of the column using the “ ” terminator: ->V2= We can define the vector either by inserting the elements of the row: ->V1= If not Scilab will output a error message: ->C=Ī vector is in fact a matrix but only with one row or column. If the first row has 4 elements, for exemple, the second row has to have the same length. The matrix definition has to be consistent. In the same way a 2×4 matrix can be defined: ->B= In the same manner rows 2 and 3 are defined. In order to complete the definition of the first row “ ” is used. First are entered the values for the first row “1 2 3”. In Scilab, a variable of type matrix is defined in the following way: ->A= It has a lot of built-in functions that allows the user to perform complex computations and manipulations on vectors (1-D matrices) and matrices. In theory it could be done with two 2D Fourier Transform (with Scilab builtin mfft maybe) but it might not be faster than this.As Matlab®, Scilab is very powerful at computations with variables such as vectors and matrices. The speed increase is about *320 (the execution time is 0.32% of your original code). You should check whether this behaviour is appropriate for you or not. Please note, that MaskFilter pads the image (the original matrix) before applying the filter, and as far as I know it uses a "mirror" array across the border. If you install the Image Processing Toolbox (IPD) you will have a MaskFilter function to do this 2D intercorrelation. This pattern can be thought as a "filter" kernel, which is a common way to modify images with a linear filter matrix. It seems to me that you want to compute a 2D intercorrelation of your heat field and a certain diffusion pattern. Any ideas on how to make it faster appreciated. Now my question is - is it necessary to do all this using for loops? Is there any built-in aggregate function in Scilab, that will let me do this for all elements of a matrix? The reason I haven't found a way yet, is that the result for every point depends on the values of other matrix points, and that made me do it with nested loops. Up to 50x50 plate, it all happens in a reasonable, 4-5 seconds time frame. Which takes quite a long time, and I'd like to avoid it. If I'd like to observe that for, say 100 secons, with a 1 s step, I have to repeat it 100 times, giving 960,400 iterations in total. The problem is, that, if I'd like to do it for a 100x100 points plate, it means, that here (it's only for inner part, without boundary conditions), I would have to loop 98x98 = 9604 times, at every turn calculating the heat at a given i,j point. Now, the crucial point of it, is calculation of temperature for all plate points, and it has to be done for every time instance I want to observe: for j=2:S-1 For this purpose, I've wrote a Scilab script. I'm trying to simulate the heat distribution on an infinite plate over time.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |