Items tagged with array array Tagged Items Feed

To gererate a random initail cofigration -1 or 1

spin = (-1).^(round(rand(N)));

 

for i=1:1000,

 

neighbours = circshift(spin, [ 0 1]) + ...

circshift(spin, [ 0 -1]) + ...

circshift(spin, [ 1 0]) + ...

circshift(spin, [-1 0]);

how to do this in maple?

I have the following command.

with(StringTools);
message := `Kajian ini mempunyai tiga objektif pertama seperti yang ditunjukkan dalam bahagian 1.11. Objektif tersebut harus`;

m := convert(message, bytes);

block := map(convert, m, binary);
block := map2(nprintf, "%08d", block);
block := map(proc (t) options operator, arrow; [seq(parse(convert(t, string)[i]), i = 1 .. length(convert(t, string)))] end proc, block);

block := [[0, 1, 0, 0, 1, 0, 1, 1], [0, 1, 1, 0, 0, 0, 0, 1], [0, 1, 1, 0, 1, 0, 1, 0], [0, 1, 1, 0, 1, 0, 0, 1], ........]

with(Bits);
for i to l do
for j from 3 to 7 do
block[i][j] := 1-block[i][j];  //used to flip bit in between 3rd to 7th bit in a block
end do;
c_block[i] := block[i];
end do;
c_block1 := [seq(c_block[i], i = 1 .. l)];

Error, assigning to a long list, please use Arrays

May i know how to solve this problem? I need to change some bit in a list but receive error when there is more than 100 elements in a list. Thank you.

How can I use a matrix in timeseriesanalysis?

 

m3 := Import("d:\\bok6.xlsx")

 

Areachart works fine:

AreaChart([m3], color = "pink" .. "niagara Navy", title = "Tidslinje Tilluft og avtrekk")

 

But when matrix m3 is entered in timeseriesanalysis it gives a error:

ts1 := TimeSeries([m3], startdate = "2016-08-1", header = "Tilluft VAV setpunkt", enddate = "2016-08-01");

Error, (in TimeSeriesAnalysis:-TimeSeries) invalid input: too many and/or wrong type of arguments passed to TimeSeries:-ModuleCopy; first unused argument is [Array(1..4, 1..1, {(1, 1) = 155.0, (2, 1) = 142.0, (3, 1) = 133.0, (4, 1) = 122.0})]

 

 

I have loaded the following packages:

with*matrix  with*linearalgebra  with(plots)  with(Statistics)  with(TimeSeriesAnalysis)

 

Regards

 

Kristian

I need to create n-order tensor filled with any symbolic variable, for exemple 'x', but "symbol" option works only on vectors and matrix, so i don't know how to do that on n-order array.

X := Vector(3, symbol = x);#------ Work
Matrix(3, 3, symbol = x);#------ Work


Array(1 .. 3, 1 .. 3, 1 .. 3, symbol = x);
Error, argument `symbol = x` is incorrect or out of order

And 2nd problem thet globaly i need to create symmetric n-order tensor with symmitry for any pair of index and with contraction for any couple of indexes equal to zero. As i understend i need to create a big list of equations for every individual pair of index and 2 conditions (contraction and symmitry) and solve it to get a match and combination of independent index and paste values in them?

 

Hello everyone!

I am wondering why the Tabulate command does not work with Explore. E.g.:

Explore(`DocumentTools:-Tabulate`([plot(sin(a*x)), plot(cos(x-a))]), parameters = [[a = 0 .. 10, controller = slider]])

I know that I can display an array of plots with the display(Array([....])) which works fine with explore but Tabulate is another good way to display multiple plots and it gives better control over individual plots properties (e.g. setting different size to different plots). Is this a bug or Tabulate is just not meant to work in that context?  

Hi,

I am solving a system of differential equations with 2 variables. I can find numerical solution using dsolve with numeric option. I can also plot curves. But I also would like to extract data at time t0 and store into a file. I don't know how to extract numerical values from dsolve and store into a text file at various time, t0, t1, t2 etc. I would like to store data in tabular format with first, sceond and third columns are time, x and y respectively.

 

Just as an example, we can use

x'(t) = y(t), 

y'(t) = 6x(t) - y(t)

with x(0)=1 and y(0) = 2

 

Thanks.

I want to define a proc in Maple which gets an integer n and gives a set of arrays like {1,2,3}^n, meaning {[a[1],...,a[n]]|for all 1<=i<=n a[i] in {1,2,3}}. For a fix n, obviously one can use n-for, for example when n is 2

A:=Array(1..3,1..3):
for a[1] from 1 by 1 to 3 do
 for a[2] from 1 by 1 to 3 do
  A(a[1],a[2]):=[a[1],a[2]];
 end for:
end for:

But when n is not fixed, how can I tell Maple to consider n for?! Also how can ask him to make a n-dimensional array?

Hi. Is there a maple function which can interpolate values from a simple table:

given (x,y) compute z value

eg z(0.5,0.5)=1.5

x:=[0,1,2];y:=[0,1,2]

array:=[0,2,4;1,3,5;2,4,6] #probably the wrong input, but you get the idea

ArrayInterpolation?

there is a method in vba:

http://www.tushar-mehta.com/excel/newsgroups/interpolation/#Two_dimensional_interpolation_

Hi,

say I have defined some (very simple, acting on a finite set M) functions f,g,h. I want to evaluate certain permutations, so I want to make a for loop that goes through possible combinations of functions in my array A=Array([f,g,h]). (In reality my array is a little larger.) No I don't understand how I can use the elements of this array as actual functions. Even if f is defined and I can evaluate, say, f(m), I cannot use A(1)(m) to evaluate m. The output is just "f(m)". How can I make maple recognize that we are having a function here?

 

Thanks it advance.

I am interested in efficiently plotting a grid of squares where each square is coloured. 

 

From what I understand I can do this using plotting primitives. For example,

P1 := Array( 1..4, 1..2, [[0,0],[1,0],[1,1],[0,1]],storage=rectangular, order=C_order, datatype=float[8] );

P2 := Array( 1..4, 1..2, [[1,1],[2,1],[2,2],[1,2]],storage=rectangular, order=C_order, datatype=float[8] );

PLOT( POLYGONS(P1,P2), COLOUR(RGB,1,0,0,0,1,0)  );

plots one red and one green unit sqaure.

 

I am interested however in plotting millions of squares.  Is there a way to efficiently store the sequence required for the POLYGONS and COLOUR primitive?  Ideally I want to store them as arrays.

Hi,

I'm trying to fill an Array but I don't know the correct syntax, and Maple help isn't much use.

How do I form an Array, A, which has 10 rows and 2 columns. Where one column is say the row number squared and the other column is the row number cubed. 

So A would be:

[1 1]
[4 8]
[9 27] .....

Also, I'm using the square and cube numbers as an example. But is there a general format for doing this, whatever the values I want to put in the array are?

Thanks

Hi,

So I'm trying to generate a .dat file that has x in the first column, then the output for y1 in the next and y2 in the following, where y1 and y2 are functions of x so the data file would look something like this from x=-5..5 in equal steps of 0.01.

-5          12           8
-4.99     7             5

etc

I'm struggling to get my head around how to do this, i understand i should use the seq function in maple and save it in array of sorts and then use writedata, but im not sure how to piece it together for having 3 columns

 

thanks in advance for any help!

Dear Maple users

I know how to fit a function with some parameters to some data, but how can it be done if the data is 2-dimensional? I mean: I have some time array T, some X array and some Y array. How do I fit a function with certain parameters to the data: (x(t),y(t)) to fit (X(T), y(T)), ...

Erik

Hello

I have such problem:

I calculated rather complicated function, and i want to obtain the array or list of data with definite step.

For this purpose I used next expression:

Out:=[seq(t,F(t),t=0..tmax,step]

I need minimum 1000 points, but calculation for the 100 points requires about 300 second, for 1000 - it will be about 3000 seconds. It's too long for me.

 

How could I accelerate this process?

 

P.S.

Plotting of my function requires about 90 seconds for the entire range. So, this is very strange, thad converting to data list requres so much time.

Hello,

I've got this error in my code and I don't know why as I didn't get it when I used a different xn function. Any help would be greatly appreciated! Thank you in advance!

Kind regards,

Gambia Man

restart

with(plots):

boxcount := proc (data, N) local n, xmax, xmin, xrange, ymax, ymin, yrange, dx, dy, i, j, ix, iy, sum, res; n := (1/2)*ArrayNumElems(data); xmax := max(seq(data[i, 1], i = 1 .. n)); xmin := min(seq(data[i, 1], i = 1 .. n)); ymax := max(seq(data[i, 2], i = 1 .. n)); ymin := min(seq(data[i, 2], i = 1 .. n)); xrange := xmax-xmin; xmin := xmin+(-1)*0.1e-1*xrange; xmax := xmax+0.1e-1*xrange; xrange := 1.02*xrange; yrange := ymax-ymin; ymin := ymin+(-1)*0.1e-1*yrange; ymax := ymax+0.1e-1*yrange; yrange := 1.02*yrange; dx := xrange/N; dy := yrange/N; res := Array(0 .. N-1, 0 .. N-1, 0); for i to n do ix := trunc((data[i, 1]-xmin)/dx); iy := trunc((data[i, 2]-ymin)/dy); res[ix, iy] := 1 end do; add(add(res[i, j], i = 0 .. N-1), j = 0 .. N-1) end proc:

``

bicationplot := proc (N) local Nr, Nt, x0, rmin, rmax, bif, k, ir, r, xn, i; global pts; Nr := 100; Nt := 200; x0 := .1; rmin := .75; rmax := 3.5; bif := Array(1 .. Nr*N, 1 .. 2); k := 1; for ir to Nr do r := rmin+ir*(rmax-rmin)/Nr; xn := x0; for i to Nt do xn := xn^2-r end do; for i to N do xn := xn^2-r; bif[k, 1] := r; bif[k, 2] := xn; k := k+1 end do end do; pts := bif end proc:

bif

bif

(1)

fractaldimension := proc (Noofitterations::integer, Npoints::integer, Nmax::integer) local res, xv, yv, line, stderrors, avgstderrors, i, avgline; avgstderrors := 0; avgline := 0; for i to Noofitterations do bicationplot(Npoints); res := [seq([1.0/n, boxcount(pts, n)], n = 1 .. Nmax, 10)]; xv := [seq(log(res[i][1]), i = 1 .. nops(res))]; yv := [seq(log(res[i][2]), i = 1 .. nops(res))]; line[i] := Fit(m*x+const, xv, yv, x, output = [leastsquaresfunction]); stderrors[i] := Fit(m*x+const, xv, yv, x, output = standarderrors) end do; for i to Noofitterations do avgstderrors := avgstderrors+stderrors[i] end do; avgstderrors := avgstderrors/Noofitterations; for i to Noofitterations do avgline := avgline+line[i] end do; avgline := avgline/Noofitterations; return FD = -(diff(avgline, x)), avgline, avgstderrors, loglogplot(res) end proc:

fractaldimension(10, 100, 100)

Error, (in boxcount) bad index into Array

 

``

 

Download First_part_fractal_determination_.mw

1 2 3 4 5 6 7 Last Page 1 of 26