Muhammad Usman

235 Reputation

5 Badges

11 years, 354 days
Beijing, China

MaplePrimes Activity


These are questions asked by Muhammad Usman

Dear Users!

I hope everyone here is fine. In the attached file I have a list of points in three dimensions. I want to plot surfaceplot (also in Dimension=2) of only those points which are less than 1.

But I want to plot the density plot for all points with the range on x-axes 5 to 15 and the range on y-axes 50-1000

Help.mw

Dear Users!

I hope everyone is fine here. In the attached file I have solved a partial differential equation using the finite difference method for different mesh in spatial directions (i.e., for different Mx). I want to compute the time and memory to compute the solution against each Mx and want to plot it. Kindly help me how to compute the time and memory for each value of Mx.

TIME.mw

I shall be waiting. Thanks in advance. 

Hi Users!

I hope everyone is fine here. I have plotted the density plot below:

restart; Digits := 20; with(LinearAlgebra); with(plots); N := 20; Mx := 20; L := 1; `&Delta;x` := L/Mx; T := 2; `&Delta;t` := T/N; for i from 0 while i <= Mx do u[i, 0] := 0 end do; for n from 0 while n <= N do u[0, n] := 0; u[Mx, n] := 0 end do; for n from 0 while n <= N-1 do for i while i <= Mx-1 do Ru[i, n] := eval((u[i, n+1]-u[i, n])/`&Delta;t` = (u[i+1, n+1]-2*u[i, n+1]+u[i-1, n+1])/`&Delta;x`^2-u[i, n+1]+.5) end do; Sol[n] := fsolve({seq(Ru[i, n], i = 1 .. Mx-1)}); assign(op(Sol[n])) end do;

Digits := 10; NP := 100; XX := [seq(seq(i1/Mx, i1 = 0 .. Mx), i2 = 0 .. N)]; TT := [seq(seq(i2, i1 = 0 .. Mx), i2 = 0 .. N)]; ZZ := [seq(seq(u[i1, i2], i2 = 0 .. N), i1 = 0 .. Mx)]; interfunc := subs(__M = Matrix(Matrix(Mx+1, N+1, ZZ), datatype = float[8]), proc (x, y) options operator, arrow; CurveFitting:-ArrayInterpolation([[`$`(i1, i1 = 0 .. Mx)], [`$`(i2, i2 = 0 .. N)]], __M, [[x], [y]], method = cubic)[1, 1] end proc); newz := CurveFitting:-ArrayInterpolation([[`$`(i1, i1 = 0 .. Mx)], [`$`(i2, i2 = 0 .. N)]], Matrix(Mx+1, N+1, ZZ, datatype = float[8]), [[seq(Mx*(i3-1)/(NP-1), i3 = 1 .. NP)], [seq(N*(i3-1)/(NP-1), i3 = 1 .. NP)]], method = cubic); nminz, nmaxz := (min, max)(newz); C := .666*(1-ImageTools:-FitIntensity(newz)); PC := PLOT(GRID(0 .. Mx, 0 .. N, newz, COLOR(HUE, C)), STYLE(PATCHNOGRID)); numcontours := 15; PP := (proc (P) options operator, arrow; (op(0, P))(op(P), ROOT(BOUNDS_X(0), BOUNDS_Y(0), BOUNDS_WIDTH(600), BOUNDS_HEIGHT(500))) end proc)(plots:-display(PC, plots:-contourplot(interfunc, 0 .. Mx, 0 .. N, thickness = 0, contours = [seq(nminz+(nmaxz-nminz)*(i3-1)/(numcontours+2-1), i3 = 1 .. numcontours+2)]), seq(plot(ZZ[1], nminz .. nminz, thickness = 15, color = COLOR(HUE, .666*(1-i3/(numcontours+1))), legend = sprintf(" %.3f", nminz+i3*(nmaxz-nminz)/(numcontours+1))), i3 = numcontours+1 .. 0, -1), legendstyle = [location = right, font = [Helvetica, 14]], font = [Helvetica, 16], labelfont = [Helvetica, bold, 16], labels = [x, t], labeldirections = [horizontal, vertical]));
plots[display](PP, size = [500, 400]);

Here the t-axis is from 0 to 20 but its actual value is from 0 to 2 and the x-axis is from 0 to 20 but its actual value is from 0 to 2. How can I change the axis? Moreover, I used the following way to extract the data in a dat file to plot the function (say f) in some professional software.

with(plots); f := plot(sin(x), x = -Pi .. Pi); dat1 := `~`[plottools:-getdata]([f]); for i while i <= 1 do A[i] := dat1[i, 3]; Y[i] := A[i][1 .. -1, 2] end do; X := A[1][1 .. -1, 1]; MM1 := `<|>`(X, `$`(Y[j2], j2 = 1 .. 1)); ExportMatrix("C:/Users/Usman/Desktop//Graph f.dat", MM1);

How I can, I extract data in the form of a dat file to plot in some professional software? 

Dear Users!

I hope everyone is fine here. I have the following functions:

f := cos(t)*sin(x)-sin(x)+(1/2)*sin(x)*t^2-(1/24)*sin(x)*t^4

I want to plot the contour plots with legends like given as (this is the countor plot just for reference):

I want the same coloring to fill the contour plots. Kindly help me to resolve my problem. Thanks in advances

Dear Users!

I hope everyone is fine. I want to plot the following sequence in 3d for t=0..1 and x=-pi..pi;

[0., 0.4995839572e-1*sin(x), 0.9966865249e-1*sin(x), .1488899476*sin(x), .1973955598*sin(x), .2449786631*sin(x), .2914567945*sin(x), .3366748194*sin(x), .3805063771*sin(x), .4228539261*sin(x), .4636476090*sin(x), .5028432109*sin(x), .5404195003*sin(x), .5763752206*sin(x), .6107259644*sin(x), .6435011088*sin(x), .6747409422*sin(x), .7044940642*sin(x), .7328151018*sin(x), .7597627549*sin(x), .7853981634*sin(x)];

In the sequence first entry (0) for t=0, second (0.4995839572e-1*sin(x)) for t=0.05, third (0.9966865249e-1*sin(x)) for t= 0.1 and so on the last entry (.7853981634*sin(x)) for t=1. In addition, how do I plot if the number of points exceeds in the sequence for example 100 or 1000 points, but the difference between two consecutive values for t is the same here the difference is Delta*t=0.05.

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