Items tagged with array array Tagged Items Feed

Here is an example of manipulating an Array of pixels. I chose the x-rite ColorChecker as a model so there would be published results to check my work. A number of details about color spaces have become clear through this exercise. The color adaptation process was modeled by converting betweenXYZ and LMS. Different black points may be selected depending on how close to zero illuminance one would accept as a good model. 

I look forward to extending this work to verify and improve the color calibration of my photography. Also some experimentation with demosaicing should be possible.

Initialization

 

restart

with(LinearAlgebra):

unprotect(gamma):``

NULL

x-rite Colorchecker xyY Matrix

  CCxyY_D50 := Matrix(4, 6, {(1, 1) = Vector(3, {(1) = .4316, (2) = .3777, (3) = .1008}), (1, 2) = Vector(3, {(1) = .4197, (2) = .3744, (3) = .3495}), (1, 3) = Vector(3, {(1) = .2760, (2) = .3016, (3) = .1836}), (1, 4) = Vector(3, {(1) = .3703, (2) = .4499, (3) = .1325}), (1, 5) = Vector(3, {(1) = .2999, (2) = .2856, (3) = .2304}), (1, 6) = Vector(3, {(1) = .2848, (2) = .3911, (3) = .4178}), (2, 1) = Vector(3, {(1) = .5295, (2) = .4055, (3) = .3118}), (2, 2) = Vector(3, {(1) = .2305, (2) = .2106, (3) = .1126}), (2, 3) = Vector(3, {(1) = .5012, (2) = .3273, (3) = .1938}), (2, 4) = Vector(3, {(1) = .3319, (2) = .2482, (3) = 0.637e-1}), (2, 5) = Vector(3, {(1) = .3984, (2) = .5008, (3) = .4446}), (2, 6) = Vector(3, {(1) = .4957, (2) = .4427, (3) = .4357}), (3, 1) = Vector(3, {(1) = .2018, (2) = .1692, (3) = 0.575e-1}), (3, 2) = Vector(3, {(1) = .3253, (2) = .5032, (3) = .2318}), (3, 3) = Vector(3, {(1) = .5686, (2) = .3303, (3) = .1257}), (3, 4) = Vector(3, {(1) = .4697, (2) = .4734, (3) = .5981}), (3, 5) = Vector(3, {(1) = .4159, (2) = .2688, (3) = .2009}), (3, 6) = Vector(3, {(1) = .2131, (2) = .3023, (3) = .1930}), (4, 1) = Vector(3, {(1) = .3469, (2) = .3608, (3) = .9131}), (4, 2) = Vector(3, {(1) = .3440, (2) = .3584, (3) = .5894}), (4, 3) = Vector(3, {(1) = .3432, (2) = .3581, (3) = .3632}), (4, 4) = Vector(3, {(1) = .3446, (2) = .3579, (3) = .1915}), (4, 5) = Vector(3, {(1) = .3401, (2) = .3548, (3) = 0.883e-1}), (4, 6) = Vector(3, {(1) = .3406, (2) = .3537, (3) = 0.311e-1})})

NULL

NULL

M := RowDimension(CCxyY_D50) = 4NULL

N := ColumnDimension(CCxyY_D50) = 6

NULL

Convert xyY to XYZ

   

NULL

CCXYZ_D50 := C_xyY_to_XYZ(CCxyY_D50):

CCXYZ_D50 = Matrix(4, 6, {(1, 1) = Vector(3, {(1) = .1152, (2) = .1008, (3) = 0.509e-1}), (1, 2) = Vector(3, {(1) = .3918, (2) = .3495, (3) = .1922}), (1, 3) = Vector(3, {(1) = .1680, (2) = .1836, (3) = .2571}), (1, 4) = Vector(3, {(1) = .1091, (2) = .1325, (3) = 0.529e-1}), (1, 5) = Vector(3, {(1) = .2419, (2) = .2304, (3) = .3344}), (1, 6) = Vector(3, {(1) = .3042, (2) = .4178, (3) = .3462}), (2, 1) = Vector(3, {(1) = .4071, (2) = .3118, (3) = 0.500e-1}), (2, 2) = Vector(3, {(1) = .1232, (2) = .1126, (3) = .2988}), (2, 3) = Vector(3, {(1) = .2968, (2) = .1938, (3) = .1015}), (2, 4) = Vector(3, {(1) = 0.852e-1, (2) = 0.637e-1, (3) = .1078}), (2, 5) = Vector(3, {(1) = .3537, (2) = .4446, (3) = 0.895e-1}), (2, 6) = Vector(3, {(1) = .4879, (2) = .4357, (3) = 0.606e-1}), (3, 1) = Vector(3, {(1) = 0.686e-1, (2) = 0.575e-1, (3) = .2138}), (3, 2) = Vector(3, {(1) = .1498, (2) = .2318, (3) = 0.790e-1}), (3, 3) = Vector(3, {(1) = .2164, (2) = .1257, (3) = 0.385e-1}), (3, 4) = Vector(3, {(1) = .5934, (2) = .5981, (3) = 0.719e-1}), (3, 5) = Vector(3, {(1) = .3108, (2) = .2009, (3) = .2356}), (3, 6) = Vector(3, {(1) = .1360, (2) = .1930, (3) = .3094}), (4, 1) = Vector(3, {(1) = .8779, (2) = .9131, (3) = .7397}), (4, 2) = Vector(3, {(1) = .5657, (2) = .5894, (3) = .4894}), (4, 3) = Vector(3, {(1) = .3481, (2) = .3632, (3) = .3029}), (4, 4) = Vector(3, {(1) = .1844, (2) = .1915, (3) = .1592}), (4, 5) = Vector(3, {(1) = 0.846e-1, (2) = 0.883e-1, (3) = 0.759e-1}), (4, 6) = Vector(3, {(1) = 0.299e-1, (2) = 0.311e-1, (3) = 0.269e-1})})NULL

XYZ D50 to XYZ D65

   

NULL

CCXYZ_D65 := XYZ_D50_to_D65(CCXYZ_D50):

CCXYZ_D65 = Matrix(4, 6, {(1, 1) = Vector(3, {(1) = .1110, (2) = 0.996e-1, (3) = 0.670e-1}), (1, 2) = Vector(3, {(1) = .3785, (2) = .3459, (3) = .2533}), (1, 3) = Vector(3, {(1) = .1726, (2) = .1861, (3) = .3403}), (1, 4) = Vector(3, {(1) = .1045, (2) = .1318, (3) = 0.690e-1}), (1, 5) = Vector(3, {(1) = .2470, (2) = .2329, (3) = .4430}), (1, 6) = Vector(3, {(1) = .3030, (2) = .4206, (3) = .4556}), (2, 1) = Vector(3, {(1) = .3850, (2) = .3044, (3) = 0.651e-1}), (2, 2) = Vector(3, {(1) = .1340, (2) = .1165, (3) = .3966}), (2, 3) = Vector(3, {(1) = .2855, (2) = .1895, (3) = .1347}), (2, 4) = Vector(3, {(1) = 0.867e-1, (2) = 0.642e-1, (3) = .1431}), (2, 5) = Vector(3, {(1) = .3334, (2) = .4409, (3) = .1142}), (2, 6) = Vector(3, {(1) = .4600, (2) = .4275, (3) = 0.777e-1}), (3, 1) = Vector(3, {(1) = 0.777e-1, (2) = 0.606e-1, (3) = .2839}), (3, 2) = Vector(3, {(1) = .1428, (2) = .2315, (3) = .1022}), (3, 3) = Vector(3, {(1) = .2063, (2) = .1216, (3) = 0.512e-1}), (3, 4) = Vector(3, {(1) = .5578, (2) = .5888, (3) = 0.906e-1}), (3, 5) = Vector(3, {(1) = .3073, (2) = .1990, (3) = .3131}), (3, 6) = Vector(3, {(1) = .1451, (2) = .1976, (3) = .4092}), (4, 1) = Vector(3, {(1) = .8646, (2) = .9129, (3) = .9759}), (4, 2) = Vector(3, {(1) = .5579, (2) = .5895, (3) = .6458}), (4, 3) = Vector(3, {(1) = .3434, (2) = .3633, (3) = .3997}), (4, 4) = Vector(3, {(1) = .1818, (2) = .1915, (3) = .2100}), (4, 5) = Vector(3, {(1) = 0.836e-1, (2) = 0.884e-1, (3) = .1002}), (4, 6) = Vector(3, {(1) = 0.296e-1, (2) = 0.311e-1, (3) = 0.355e-1})})

NULL

NULLConvert XYZ to Lab (D50 or D65 White Point)

 

NULLNULL

Reference White Point for D50

NULL

X_D50wht := XYZ_D50wht[1] = .96422NULL

Y_D50wht := XYZ_D50wht[2] = 1NULL

Z_D50wht := XYZ_D50wht[3] = .82521

NULL

Lab Conversion Constants;

`ε` := 216/24389:

kappa := 24389/27:

NULL

fx_D50 := proc (XYZ) options operator, arrow; piecewise(`&epsilon;` < XYZ[1]/X_D50wht, (XYZ[1]/X_D50wht)^(1/3), XYZ[1]/X_D50wht <= `&epsilon;`, (1/116)*kappa*XYZ[1]/X_D50wht+4/29) end proc
                

NULLNULL

NULL

 
fy_D50 := proc (XYZ) options operator, arrow; piecewise(`&epsilon;` < XYZ[2]/Y_D50wht, (XYZ[2]/Y_D50wht)^(1/3), XYZ[2]/Y_D50wht <= `&epsilon;`, (1/116)*kappa*XYZ[2]/Y_D50wht+4/29) end proc
NULLNULL

NULLNULL

fz_D50 := proc (XYZ) options operator, arrow; piecewise(`&epsilon;` < XYZ[3]/Z_D50wht, (XYZ[3]/Z_D50wht)^(1/3), XYZ[3]/Z_D50wht <= `&epsilon;`, (1/116)*kappa*XYZ[3]/Z_D50wht+4/29) end proc
NULL

XYZ_to_Lab_D50 := proc (XYZ) options operator, arrow; `<,>`(116*fy_D50(XYZ)-16, 500*fx_D50(XYZ)-500*fy_D50(XYZ), 200*fy_D50(XYZ)-200*fz_D50(XYZ)) end proc:

NULL

Reference White Point for D65

NULL

X_D65wht := XYZ_D65wht[1] = .95047NULL

Y_D65wht := XYZ_D65wht[2] = 1NULL

Z_D65wht := XYZ_D65wht[3] = 1.08883 

NULL

NULL

NULL

NULL

NULL

NULL

NULL

fx_D65 := proc (XYZ) options operator, arrow; piecewise(`&epsilon;` < XYZ[1]/X_D65wht, (XYZ[1]/X_D65wht)^(1/3), XYZ[1]/X_D65wht <= `&epsilon;`, (1/116)*kappa*XYZ[1]/X_D65wht+4/29) end proc
                

NULLNULL

NULL

 
fy_D65 := proc (XYZ) options operator, arrow; piecewise(`&epsilon;` < XYZ[2]/Y_D65wht, (XYZ[2]/Y_D65wht)^(1/3), XYZ[2]/Y_D65wht <= `&epsilon;`, (1/116)*kappa*XYZ[2]/Y_D65wht+4/29) end proc
NULLNULL

NULLNULL

fz_D65 := proc (XYZ) options operator, arrow; piecewise(`&epsilon;` < XYZ[3]/Z_D65wht, (XYZ[3]/Z_D65wht)^(1/3), XYZ[3]/Z_D65wht <= `&epsilon;`, (1/116)*kappa*XYZ[3]/Z_D65wht+4/29) end proc
NULL

XYZ_to_Lab_D65 := proc (XYZ) options operator, arrow; `<,>`(116*fy_D65(XYZ)-16, 500*fx_D65(XYZ)-500*fy_D65(XYZ), 200*fy_D65(XYZ)-200*fz_D65(XYZ)) end proc:

NULL

NULL

 

NULL

C_XYZ_to_Lab := proc (XYZ, L) options operator, arrow; piecewise(evalb(L = D50), Array([`$`('[`$`('XYZ_to_Lab_D50(XYZ[m, n])', n = 1 .. N)]', m = 1 .. M)]), evalb(L = D65), Array([`$`('[`$`('XYZ_to_Lab_D65(XYZ[m, n])', n = 1 .. N)]', m = 1 .. M)])) end proc
 NULL

NULL

NULLNULL

NULL

CCLab_D50 := C_XYZ_to_Lab(CCXYZ_D50, D50): NULL

CCLab_D50 = Matrix(4, 6, {(1, 1) = Vector(3, {(1) = 37.99, (2) = 13.55, (3) = 14.06}), (1, 2) = Vector(3, {(1) = 65.71, (2) = 18.14, (3) = 17.82}), (1, 3) = Vector(3, {(1) = 49.93, (2) = -4.91, (3) = -21.92}), (1, 4) = Vector(3, {(1) = 43.14, (2) = -13.10, (3) = 21.89}), (1, 5) = Vector(3, {(1) = 55.11, (2) = 8.84, (3) = -25.39}), (1, 6) = Vector(3, {(1) = 70.72, (2) = -33.39, (3) = -.21}), (2, 1) = Vector(3, {(1) = 62.66, (2) = 36.06, (3) = 57.08}), (2, 2) = Vector(3, {(1) = 40.01, (2) = 10.42, (3) = -45.98}), (2, 3) = Vector(3, {(1) = 51.13, (2) = 48.24, (3) = 16.26}), (2, 4) = Vector(3, {(1) = 30.33, (2) = 23.00, (3) = -21.59}), (2, 5) = Vector(3, {(1) = 72.53, (2) = -23.70, (3) = 57.27}), (2, 6) = Vector(3, {(1) = 71.94, (2) = 19.37, (3) = 67.86}), (3, 1) = Vector(3, {(1) = 28.77, (2) = 14.17, (3) = -50.30}), (3, 2) = Vector(3, {(1) = 55.26, (2) = -38.32, (3) = 31.36}), (3, 3) = Vector(3, {(1) = 42.11, (2) = 53.38, (3) = 28.20}), (3, 4) = Vector(3, {(1) = 81.73, (2) = 4.03, (3) = 79.85}), (3, 5) = Vector(3, {(1) = 51.94, (2) = 50.00, (3) = -14.57}), (3, 6) = Vector(3, {(1) = 51.04, (2) = -28.65, (3) = -28.63}), (4, 1) = Vector(3, {(1) = 96.54, (2) = -.46, (3) = 1.19}), (4, 2) = Vector(3, {(1) = 81.26, (2) = -.64, (3) = -.35}), (4, 3) = Vector(3, {(1) = 66.76, (2) = -.72, (3) = -.51}), (4, 4) = Vector(3, {(1) = 50.86, (2) = -.14, (3) = -.28}), (4, 5) = Vector(3, {(1) = 35.65, (2) = -.44, (3) = -1.23}), (4, 6) = Vector(3, {(1) = 20.48, (2) = -0.7e-1, (3) = -.98})})NULL

NULL

Convert XYZ to aRGB (XYZ D50 or D65 to aRGB D65)

 

XYZ Scaling for aRGB Ymax,Ymin (Ref. Adobe RGB (1998) Color Image Encoding Section 4.3.2.2 and 4.3.8)

NULL

White Point (Luminance=160Cd/m^2) D65

Black Point (Luminance=0.5557Cd/m^2) D65

White Point (Luminance=160Cd/m^2) D50

Black Point (Luminance=0.5557Cd/m^2) D50

XW_D65 := 152.07*(1/160) = .9504375000NULL

YW_D65 := 160*(1/160) = 1``

ZW_D65 := 174.25*(1/160) = 1.089062500``

NULL

xXK_D65 := .5282*(1/160) = 0.3301250000e-2``

xYK_D65 := .5557*(1/160) = 0.3473125000e-2``

xZK_D65 := .6025*(1/160) = 0.3765625000e-2``

XK_D65 := 0:

YK_D65 := 0:

ZK_D65 := 0:

``

``

XW_D50 := .9462:NULL

YW_D50 := 1.0000:

ZW_D50 := .8249:

``

NULL

xXK_D50 := 0.33488e-2:

xYK_D50 := 0.34751e-2:

xZK_D50 := 0.28650e-2:

``

XK_D50 := 0:

YK_D50 := 0:

ZK_D50 := 0:

NULL

 

NULL

XYZD65_to_aXYZ := proc (XYZ) options operator, arrow; `<,>`((XYZ[1]-XK_D65)*XW_D65/((XW_D65-XK_D65)*YW_D65), (XYZ[2]-YK_D65)/(YW_D65-YK_D65), (XYZ[3]-ZK_D65)*ZW_D65/((ZW_D65-ZK_D65)*YW_D65)) end proc:

XYZD50_to_aXYZ := proc (XYZ) options operator, arrow; `<,>`((XYZ[1]-XK_D50)*XW_D50/((XW_D50-XK_D50)*YW_D50), (XYZ[2]-YK_D50)/(YW_D50-YK_D50), (XYZ[3]-ZK_D50)*ZW_D50/((ZW_D50-ZK_D50)*YW_D50)) end proc:

 

NULL

(ref. Adobe RGB(1998) section 4.3.6.1, Bradford Matrix includes D50 to D65 adaptation)

M_XYZtoaRGB_D50 := Matrix(3, 3, {(1, 1) = 1.96253, (1, 2) = -.61068, (1, 3) = -.34137, (2, 1) = -.97876, (2, 2) = 1.91615, (2, 3) = 0.3342e-1, (3, 1) = 0.2869e-1, (3, 2) = -.14067, (3, 3) = 1.34926})

  aXYZ_to_RGB_D50 := proc (aXYZ) options operator, arrow; `<,>`(Typesetting:-delayDotProduct(M_XYZtoaRGB_D50, aXYZ)) end proc: NULL

 

(ref. Adobe RBG(1998) section 4.3.4.1, Bradford Matrix assumes XYZ is D65)

M_XYZtoaRGB_D65 := Matrix(3, 3, {(1, 1) = 2.04159, (1, 2) = -.56501, (1, 3) = -.34473, (2, 1) = -.96924, (2, 2) = 1.87597, (2, 3) = 0.4156e-1, (3, 1) = 0.1344e-1, (3, 2) = -.11836, (3, 3) = 1.01517})

  NULL

aXYZ_to_RGB_D65 := proc (aXYZ) options operator, arrow; `<,>`(Typesetting:-delayDotProduct(M_XYZtoaRGB_D65, aXYZ)) end proc:

NULL

  aRGB Expansion for 8bits

 

`&gamma;a` := 2.19921875:

RGB_to_aRGB := proc (RGB) options operator, arrow; `<,>`(round(255*Norm(RGB[1])^(1/`&gamma;a`)), round(255*Norm(RGB[2])^(1/`&gamma;a`)), round(255*Norm(RGB[3])^(1/`&gamma;a`))) end proc:
NULL

 

Combine Steps

NULL

XYZ_to_aRGB := proc (XYZ, L) options operator, arrow; piecewise(evalb(L = D50), Array([`$`('[`$`('RGB_to_aRGB(aXYZ_to_RGB_D50(XYZD50_to_aXYZ(XYZ[m, n])))', n = 1 .. N)]', m = 1 .. M)]), evalb(L = D65), Array([`$`('[`$`('RGB_to_aRGB(aXYZ_to_RGB_D65(XYZD65_to_aXYZ(XYZ[m, n])))', n = 1 .. N)]', m = 1 .. M)])) end proc

NULLNULL

NULLNULL

Note: The aRGB values published for ColorChecker assume a black point of 0cd/m^2.

````

aRGB_D50in := XYZ_to_aRGB(CCXYZ_D50, D50):

aRGB_D50in = Matrix(4, 6, {(1, 1) = Vector(3, {(1) = 107, (2) = 82, (3) = 70}), (1, 2) = Vector(3, {(1) = 184, (2) = 146, (3) = 128}), (1, 3) = Vector(3, {(1) = 101, (2) = 122, (3) = 153}), (1, 4) = Vector(3, {(1) = 95, (2) = 107, (3) = 69}), (1, 5) = Vector(3, {(1) = 128, (2) = 127, (3) = 173}), (1, 6) = Vector(3, {(1) = 129, (2) = 188, (3) = 171}), (2, 1) = Vector(3, {(1) = 201, (2) = 123, (3) = 56}), (2, 2) = Vector(3, {(1) = 77, (2) = 92, (3) = 166}), (2, 3) = Vector(3, {(1) = 174, (2) = 83, (3) = 97}), (2, 4) = Vector(3, {(1) = 86, (2) = 61, (3) = 104}), (2, 5) = Vector(3, {(1) = 167, (2) = 188, (3) = 75}), (2, 6) = Vector(3, {(1) = 213, (2) = 160, (3) = 55}), (3, 1) = Vector(3, {(1) = 49, (2) = 65, (3) = 143}), (3, 2) = Vector(3, {(1) = 99, (2) = 148, (3) = 80}), (3, 3) = Vector(3, {(1) = 155, (2) = 52, (3) = 59}), (3, 4) = Vector(3, {(1) = 227, (2) = 197, (3) = 52}), (3, 5) = Vector(3, {(1) = 169, (2) = 85, (3) = 147}), (3, 6) = Vector(3, {(1) = 61, (2) = 135, (3) = 167}), (4, 1) = Vector(3, {(1) = 245, (2) = 245, (3) = 242}), (4, 2) = Vector(3, {(1) = 200, (2) = 201, (3) = 201}), (4, 3) = Vector(3, {(1) = 160, (2) = 161, (3) = 162}), (4, 4) = Vector(3, {(1) = 120, (2) = 120, (3) = 121}), (4, 5) = Vector(3, {(1) = 84, (2) = 85, (3) = 86}), (4, 6) = Vector(3, {(1) = 52, (2) = 53, (3) = 54})})NULL

  

NULL

aRGB_D65in := XYZ_to_aRGB(CCXYZ_D65, D65):

aRGB_D65in = Matrix(4, 6, {(1, 1) = Vector(3, {(1) = 107, (2) = 82, (3) = 70}), (1, 2) = Vector(3, {(1) = 184, (2) = 146, (3) = 128}), (1, 3) = Vector(3, {(1) = 101, (2) = 122, (3) = 153}), (1, 4) = Vector(3, {(1) = 95, (2) = 107, (3) = 69}), (1, 5) = Vector(3, {(1) = 128, (2) = 127, (3) = 173}), (1, 6) = Vector(3, {(1) = 129, (2) = 188, (3) = 171}), (2, 1) = Vector(3, {(1) = 201, (2) = 123, (3) = 56}), (2, 2) = Vector(3, {(1) = 77, (2) = 92, (3) = 166}), (2, 3) = Vector(3, {(1) = 174, (2) = 83, (3) = 97}), (2, 4) = Vector(3, {(1) = 86, (2) = 61, (3) = 104}), (2, 5) = Vector(3, {(1) = 167, (2) = 188, (3) = 75}), (2, 6) = Vector(3, {(1) = 213, (2) = 160, (3) = 55}), (3, 1) = Vector(3, {(1) = 49, (2) = 65, (3) = 143}), (3, 2) = Vector(3, {(1) = 99, (2) = 148, (3) = 80}), (3, 3) = Vector(3, {(1) = 155, (2) = 52, (3) = 59}), (3, 4) = Vector(3, {(1) = 227, (2) = 197, (3) = 52}), (3, 5) = Vector(3, {(1) = 169, (2) = 85, (3) = 147}), (3, 6) = Vector(3, {(1) = 61, (2) = 135, (3) = 167}), (4, 1) = Vector(3, {(1) = 245, (2) = 245, (3) = 242}), (4, 2) = Vector(3, {(1) = 200, (2) = 201, (3) = 201}), (4, 3) = Vector(3, {(1) = 160, (2) = 161, (3) = 162}), (4, 4) = Vector(3, {(1) = 120, (2) = 120, (3) = 121}), (4, 5) = Vector(3, {(1) = 84, (2) = 85, (3) = 86}), (4, 6) = Vector(3, {(1) = 52, (2) = 53, (3) = 54})})

Convert XYZ to ProPhoto RGB (D50)

   

NULL

CC_PPhoto := XYZ_to_PPhoto(CCXYZ_D50):

NULL

CC_PPhoto = Matrix(4, 6, {(1, 1) = Vector(3, {(1) = 81, (2) = 67, (3) = 54}), (1, 2) = Vector(3, {(1) = 159, (2) = 135, (3) = 113}), (1, 3) = Vector(3, {(1) = 94, (2) = 102, (3) = 133}), (1, 4) = Vector(3, {(1) = 75, (2) = 86, (3) = 55}), (1, 5) = Vector(3, {(1) = 118, (2) = 111, (3) = 154}), (1, 6) = Vector(3, {(1) = 127, (2) = 168, (3) = 157}), (2, 1) = Vector(3, {(1) = 167, (2) = 118, (3) = 54}), (2, 2) = Vector(3, {(1) = 79, (2) = 74, (3) = 145}), (2, 3) = Vector(3, {(1) = 141, (2) = 83, (3) = 80}), (2, 4) = Vector(3, {(1) = 68, (2) = 49, (3) = 82}), (2, 5) = Vector(3, {(1) = 144, (2) = 170, (3) = 74}), (2, 6) = Vector(3, {(1) = 181, (2) = 152, (3) = 60}), (3, 1) = Vector(3, {(1) = 57, (2) = 50, (3) = 120}), (3, 2) = Vector(3, {(1) = 85, (2) = 123, (3) = 69}), (3, 3) = Vector(3, {(1) = 120, (2) = 59, (3) = 46}), (3, 4) = Vector(3, {(1) = 199, (2) = 188, (3) = 66}), (3, 5) = Vector(3, {(1) = 143, (2) = 85, (3) = 127}), (3, 6) = Vector(3, {(1) = 78, (2) = 111, (3) = 148}), (4, 1) = Vector(3, {(1) = 242, (2) = 243, (3) = 240}), (4, 2) = Vector(3, {(1) = 189, (2) = 190, (3) = 191}), (4, 3) = Vector(3, {(1) = 145, (2) = 146, (3) = 146}), (4, 4) = Vector(3, {(1) = 102, (2) = 102, (3) = 102}), (4, 5) = Vector(3, {(1) = 66, (2) = 66, (3) = 68}), (4, 6) = Vector(3, {(1) = 37, (2) = 37, (3) = 38})})NULL

Convert XYZ to sRGB (XYZ D50 or D65 to sRGB D65)

   

NULL

Note: The sRGB values published for ColorChecker assume a black point of 0cd/m^2.

``

CCsRGB_D65in := XYZ_to_sRGB(CCXYZ_D65, D65):

NULL

CCsRGB_D65in = Matrix(4, 6, {(1, 1) = Vector(3, {(1) = 115, (2) = 81, (3) = 67}), (1, 2) = Vector(3, {(1) = 199, (2) = 147, (3) = 129}), (1, 3) = Vector(3, {(1) = 91, (2) = 122, (3) = 156}), (1, 4) = Vector(3, {(1) = 90, (2) = 108, (3) = 64}), (1, 5) = Vector(3, {(1) = 130, (2) = 128, (3) = 176}), (1, 6) = Vector(3, {(1) = 92, (2) = 190, (3) = 172}), (2, 1) = Vector(3, {(1) = 224, (2) = 124, (3) = 47}), (2, 2) = Vector(3, {(1) = 68, (2) = 91, (3) = 170}), (2, 3) = Vector(3, {(1) = 198, (2) = 82, (3) = 97}), (2, 4) = Vector(3, {(1) = 94, (2) = 58, (3) = 106}), (2, 5) = Vector(3, {(1) = 159, (2) = 189, (3) = 63}), (2, 6) = Vector(3, {(1) = 230, (2) = 162, (3) = 39}), (3, 1) = Vector(3, {(1) = 35, (2) = 63, (3) = 147}), (3, 2) = Vector(3, {(1) = 67, (2) = 149, (3) = 74}), (3, 3) = Vector(3, {(1) = 180, (2) = 49, (3) = 57}), (3, 4) = Vector(3, {(1) = 238, (2) = 198, (3) = 20}), (3, 5) = Vector(3, {(1) = 193, (2) = 84, (3) = 151}), (3, 6) = Vector(3, {(1) = 54, (2) = 136, (3) = 170}), (4, 1) = Vector(3, {(1) = 245, (2) = 245, (3) = 243}), (4, 2) = Vector(3, {(1) = 200, (2) = 202, (3) = 202}), (4, 3) = Vector(3, {(1) = 161, (2) = 163, (3) = 163}), (4, 4) = Vector(3, {(1) = 121, (2) = 121, (3) = 122}), (4, 5) = Vector(3, {(1) = 82, (2) = 84, (3) = 86}), (4, 6) = Vector(3, {(1) = 49, (2) = 49, (3) = 51})})NULL

``

CCsRGB_D50in := XYZ_to_sRGB(CCXYZ_D50, D50):

``

CCsRGB_D50in = Matrix(4, 6, {(1, 1) = Vector(3, {(1) = 115, (2) = 81, (3) = 67}), (1, 2) = Vector(3, {(1) = 199, (2) = 148, (3) = 129}), (1, 3) = Vector(3, {(1) = 91, (2) = 123, (3) = 156}), (1, 4) = Vector(3, {(1) = 90, (2) = 108, (3) = 64}), (1, 5) = Vector(3, {(1) = 130, (2) = 129, (3) = 176}), (1, 6) = Vector(3, {(1) = 92, (2) = 190, (3) = 172}), (2, 1) = Vector(3, {(1) = 224, (2) = 125, (3) = 47}), (2, 2) = Vector(3, {(1) = 68, (2) = 92, (3) = 170}), (2, 3) = Vector(3, {(1) = 198, (2) = 83, (3) = 97}), (2, 4) = Vector(3, {(1) = 94, (2) = 59, (3) = 106}), (2, 5) = Vector(3, {(1) = 159, (2) = 190, (3) = 63}), (2, 6) = Vector(3, {(1) = 230, (2) = 163, (3) = 39}), (3, 1) = Vector(3, {(1) = 35, (2) = 64, (3) = 147}), (3, 2) = Vector(3, {(1) = 67, (2) = 149, (3) = 74}), (3, 3) = Vector(3, {(1) = 180, (2) = 51, (3) = 57}), (3, 4) = Vector(3, {(1) = 238, (2) = 199, (3) = 20}), (3, 5) = Vector(3, {(1) = 193, (2) = 85, (3) = 151}), (3, 6) = Vector(3, {(1) = 54, (2) = 137, (3) = 170}), (4, 1) = Vector(3, {(1) = 245, (2) = 246, (3) = 243}), (4, 2) = Vector(3, {(1) = 200, (2) = 203, (3) = 202}), (4, 3) = Vector(3, {(1) = 161, (2) = 164, (3) = 163}), (4, 4) = Vector(3, {(1) = 121, (2) = 122, (3) = 122}), (4, 5) = Vector(3, {(1) = 82, (2) = 84, (3) = 86}), (4, 6) = Vector(3, {(1) = 49, (2) = 50, (3) = 51})})``

NULL

``

NULL

NULL

``

 

 

 

 

 

 

 

 

``

 

Download Pixel_Conversion.mw

 

i have a work on Magic Squares , and i need to rotate or flip them to all 8 possible directions .
but i am confused to find such special commands in maple for doing my purpose !

may you guide me how can i do this programmaticaly ?

 

order4 := Array(1 .. 4, 1 .. 4, {(1, 1) = 8, (1, 2) = 11, (1, 3) = 14, (1, 4) = 1, (2, 1) = 13, (2, 2) = 2, (2, 3) = 7, (2, 4) = 12, (3, 1) = 3, (3, 2) = 16, (3, 3) = 9, (3, 4) = 6, (4, 1) = 10, (4, 2) = 5, (4, 3) = 4, (4, 4) = 15}, datatype = anything, storage = rectangular, order = Fortran_order)

order4 := Array(1..4, 1..4, {(1, 1) = 8, (1, 2) = 11, (1, 3) = 14, (1, 4) = 1, (2, 1) = 13, (2, 2) = 2, (2, 3) = 7, (2, 4) = 12, (3, 1) = 3, (3, 2) = 16, (3, 3) = 9, (3, 4) = 6, (4, 1) = 10, (4, 2) = 5, (4, 3) = 4, (4, 4) = 15})

(1)

``


Download magicsquare4.mw

i have read data from a text file. i want to convert this data to array,how should i do that ?

for example :
 i have readed these files and i want convert them to array which for the first one,has 3 rows and 4 columns.
what should i do ?

restart:

FileTools[Text][ReadFile]("NLIST.txt");

"       1     0.00000000000       0.00000000000       0.00000000000    
       2     50.0000000000       0.00000000000       0.00000000000    
       3     25.0000000000       0.00000000000       0.00000000000
        

"

(1)

op(FileTools[Text][ReadFile]("ELIST.txt"));

"       1   1   1   1   0   1      1     3     0
       2   1   1   1   0   1      3     2     0

      
      "

(2)

 

NULL


Download convert_to_array.mw   ELIST.txt  NLIST.txt

I have a rank 1 array M of 1000 values.

I want to apply a function f on each value of M and its location giving,

[f(1,M[1]), f(2,M[2]), ... , f(1000,M[1000])]

is it possible to get this using map or map2 or map[n] or maptype (without using seq since its slowing down computation).

inotherwords can i access the member location inside a map evaluation?

want to export to excel to file from matrix

Error, (in FindLambda) invalid input: `convert/Array` expects its 1st argument, A, to be of type {Array, Matrix, Vector, array, list, listlist}, but received csvfile
csvfile = Matrix(30,7);

print(close3(t+i), rhs(Sol5[1][1]), ratioA, oddsratio, oddsratioSimUp, oddsratioSimDown,1);
csvfile[i+1,1] := close3(t+i);
csvfile[i+1,2] := rhs(Sol5[1][1]);
csvfile[i+1,3] := ratioA;
csvfile[i+1,4] := oddsratio;
csvfile[i+1,5] := oddsratioSimUp;
csvfile[i+1,6] := oddsratioSimDown;
csvfile[i+1,7] := 1;

29.95, 0.03355620525, 0.7651906074, 0.6000000000, 0.5294117647,

0.5714285714, 0
-8
29.95, 0.03361194645, 1.750709592 10 , 0.4444444444,

0.5000000000, 0.6000000000, 0
5
29.6, 0.03432592221, 1.013882143 10 , 0.6000000000, 0.4444444444,

0.6923076923, 1
29.55, 0.03447081290, -0.000009845029875, 0.7142857143,

0.6000000000, 0.5000000000, 0
29.8, 0.03403562903, 30660.46200, 0.5294117647, 0.4117647059,

0.7142857143, 0
30.4, 0.03327345914, -0.5761838946, 0.6000000000, 0.5714285714,

0.5294117647, 0
30.3, 0.03376575281, 6.256895964, 0.5000000000, 0.6000000000,

0.5000000000, 0
30.95, 0.03231017771, 0.5328449644, 0.6000000000, 0.6000000000,

0.5000000000, 0
31.1, 0.03104289658, -26.93771895, 0.5000000000, 0.5000000000,

0.6000000000, 0
29.2, 0.03366016138, -0.08555779615, 0.4444444444, 0.5000000000,

0.6000000000, 0
28.95, 0.03415453360, 0.4007940838, 0.6000000000, 0.4444444444,

0.6923076923, 0
28.3, 0.03605364033, 0.00001875789432, 0.3750000000,

0.6000000000, 0.5000000000, 0
28.75, 0.03523629490, 0.9740829247, 0.4117647059, 0.7333333333,

0.3750000000, 1
5
29.2, 0.03415861325, -6.244828641 10 , 0.6000000000,

0.7142857143, 0.4117647059, 1
28.8, 0.03514419367, -0.1430744128, 0.06666666667, 0.6000000000,

0.5000000000, 0
29.4, 0.03352191217, 0.1495513336, 0.5000000000, 1.000000000,

0.06666666667, 0
28.95, 0.03433350933, 2.034565984, 0.5000000000, 0.5000000000,

0.6000000000, 0
28.85, 0.03394117064, 16.52857996, 0.7142857143, 0.5000000000,

0.6000000000, 0
28.5, 0.03419513697, -67.32086106, 0.6000000000, 0.7142857143,

0.4117647059, 0
-8
27.05, 0.03748108008, -3.316856585 10 , 0.6000000000,

0.6000000000, 0.5000000000, 0
27.7, 0.03561234996, 0.9992012832, 0.5000000000, 0.5000000000,

0.6000000000, 1
7
27.25, 0.03636057571, -1.891574002 10 , 0.5000000000,

0.5000000000, 0.6000000000, 1
27.0, 0.03696844993, 1.002386970, 0.03225806452, 0.5000000000,

0.6000000000, 0
-8
26.85, 0.03745201461, -5.221638895 10 , 1.000000000,

0.03225806452, 0, 0
26.85, 0.03734798123, 1.050118943, 0.5000000000, 0.06666666667,

1.000000000, 1

Hi everyone

Title might be misleading but couldn't come up with a short version of my problem.

The idea is to show an animation of several plots of an array, which all have different values in the positive and in the negative range. For distinguishing purposes I want to show positive values in a different colour than the negative values.

For better understanding imagine a chess board with the rows and columns and there are places with values, black chess pieces as positive values and white chess pieces as negative values. Each array in the sequence from A1 to An shows a movement.

For the plots I use sparsematrixplot which unfortunately just shows all non-zero values. So I seperated the original array and made two arrays, one with the positive values and one with the negative values. I am able to animate the sequence of several plots and can play the animation of two sequences consecutively with following:

A:=seq(sparsematrixplot(convert(H||g,matrix),color=green,view=[0..10,0..10]),g=1..G):
B:=seq(sparsematrixplot(convert(F||g,matrix),color=red,view=[0..10,0..10]),g=1..G):
display([A,B], insequence=true);

Hence my questions
1. Is it possible to plot an array with different colours for different values and can I animate these plots?

2. If not, is there a way to display the two plot sequences on top of each other?

 

Thanks for your help in advance.

Hallo,

Is there a fairly straightforward method for obtaining an array of coordinates from an implicit equation? I have an ellipse defined implicitly (by a horrendously involved expression) and can't figure out how to extract a set of coordinates from an implicitplot. I'm reluctant to use seq and fsolve with a fixed stepsize.

Would be grateful for some insight!

Thanks.

Weirp

I saw the expression:

proc(a::array(1, mumeric))

the decration of a is array(a, numeric).

But, I can't find still now the expression of array(a, numeric) in HELP in maple.

In the term of array, it is written that it takes as arguments indexfcn, bounds, list.

as in  array( indexfcn, bounds, list).

1 in array(1, mumeric)) is bounds, and probably numeric in array might mean each terms of the array such as (1,2,3)

has to take the property of being numeric. But, it is not written in the term of array in the HELP of Maple.

Where can I find that syntax of array of array(1, numeric)?

 

Thanks in advance.

 

taro 

 

 

 

 

Hi,

I have a linear system to solve.

 

mm:=proc(a,x,h,i)
local A,Z1,Z2,Z,F,result;  # to declare the local variable
A:=array(1..2,1..2,[[1,1],[a,a+h]]);
Z1:=evalf(int(1/(abs(y-x)+.000000001),y=a..a+h));
Z2:=evalf(int(y/(abs(y-x)+.000000001),y=a..a+h));
Z:=array([Z1,Z2]);
F:=evalm(inverse(A)&*Z);
result:=F[i]
end:

My questions: 

1) My exact Z1 is Z1:=evalf(int(1/(abs(y-x)),y=a..a+h)); but I ask if can I put

Z1:=evalf(int(1/(abs(y-x)+.000000001),y=a..a+h));

the same for Z2.

2) Can I writte in a simple form the vector Z.  Because, later, il have a second system contains Z1,Z2, Z3, Z4,Z5.  The difference between Z1 and Z2 is the variable "y" added in the integral of Z2.

 

Many thinks.

 

It's been a while since I touched Maple. Just picked it up again to do some stat work, and I'm feeling a bit out of my element having been to accustomed to things like Matl.... (I mean the software that shall not be named).

Is there a way to convert a single array/matrix into multiple arrays?

 Scenario:

1 1
2 7
3 8
4 9
5 10
6 14
7 20

It's easy just to copy and past this as a single element within a worksheet. However, I want to get it so that it's formated like data = [[1,1],[2,7],[3,8],etc...]

Is there a way to reformat into individual elements once everything is in one large array? I'm basically copy and pasting a huge mess of cells from Excel and am looking to see if there's a simplier solution than manual data entry.

Hi,

I want to display the matrix M, I used return M, in this procedure, but no matrix M displayed.

restart;
N:=2:
N:=2;
ff:=proc(N)
local M,i,p;
M:=array(1..2*N+1,1..2*N+1):
for i from 1 to 2*N+1 do
for  p from 1  to 2*N+1  do
   if p=1 then M[p,i]:=-2;
    elif  p=2*N+1  then M[p,i]:=-3;
else
M[p,i]:=0;
end if; end do; end do;
return M;
end proc;

 

Many thinks

Hi All,

I used the command map to apply a procedure to elements of a array like this:

 

Why did I get the null array "[]"?

A vector was also used and got the similar result: 

 

I'd appreciate any help on this topic. Thank a lot.

Hello,

As a means of encoding information, I'm working with nested array objects (I had originally used lists, but they became too large and Maple suggested that I use arrays). The nesting should be at most four deep, but the nested arrays can have varying lengths. In order to work with the arrays, I have a series of procedures that manipulate a given array and update the existing array object to contain the result. The issue that I have is that one of my procedures needs to simultaneously use both the original array and a modified version of the array, but once the modification is performed, the original version no longer exists.

Ultimately, my issue boils down to this: is there a clean (or messy, I'm not picky) way to duplicate an array so that there are two copies of the array in memory? Just writting Array2 := Array1 just creates another pointer to the same array in memory from what I can tell, so that doesn't work. There is a function copy, but it doesn't seem to work on nested arrays. 

For example, running the following does not modify Array2.

Array1 := Array([Array([1, 2]), Array([3, 4])]);
Array2 := Array([Array([1, 2]), Array([5, 6])]);
copy(Array1, Array2);

Indeed, neither does

Array1 := Array([Array([1, 2]), Array([3, 4])]);
Array2 := Array([Array([1, 2]), Array([5, 6])]);
copy(Array1(2), Array2(2));

Unfortunately, the latter case would seem to mean that I can't just write a procedure to recurse through my layers of arrays and copy piecewise either.

Thanks in advance for any help.

Please see the attached worksheet for the error at the end, any idea what happens?

Besides, anyone know how to make plot array with each element has a plot and scatterplot in it?  I made my plot by making table first and then type the cmd individually.

Raw Data

restart

avicel102_aero200 := Matrix(12, 3, {(1, 1) = 50, (1, 2) = 1.6621, (1, 3) = .22, (2, 1) = 100, (2, 2) = 3.33221, (2, 3) = .103, (3, 1) = 150, (3, 2) = 4.95533, (3, 3) = 0.43e-1, (4, 1) = 200, (4, 2) = 5.62147, (4, 3) = 0.37e-1, (5, 1) = 50, (5, 2) = 1.88627, (5, 3) = .207, (6, 1) = 50, (6, 2) = 1.90375, (6, 3) = .199, (7, 1) = 100, (7, 2) = 4.04708, (7, 3) = 0.89e-1, (8, 1) = 100, (8, 2) = 4.20413, (8, 3) = 0.87e-1, (9, 1) = 150, (9, 2) = 5.50509, (9, 3) = 0.41e-1, (10, 1) = 150, (10, 2) = 4.90453, (10, 3) = 0.49e-1, (11, 1) = 200, (11, 2) = 6.22001, (11, 3) = 0.16e-1, (12, 1) = 200, (12, 2) = 6.24435, (12, 3) = 0.23e-1}); avicel102_syloid := Matrix(13, 3, {(1, 1) = 50, (1, 2) = 1.76578, (1, 3) = .235, (2, 1) = 100, (2, 2) = 4.08314, (2, 3) = .128, (3, 1) = 150, (3, 2) = 4.85921, (3, 3) = 0.73e-1, (4, 1) = 200, (4, 2) = 5.66786, (4, 3) = 0.51e-1, (5, 1) = 50, (5, 2) = 2.06221, (5, 3) = .224, (6, 1) = 50, (6, 2) = 2.17294, (6, 3) = .216, (7, 1) = 100, (7, 2) = 4.03728, (7, 3) = .109, (8, 1) = 100, (8, 2) = 3.67978, (8, 3) = .116, (9, 1) = 150, (9, 2) = 5.78427, (9, 3) = 0.6e-1, (10, 1) = 150, (10, 2) = 5.43599, (10, 3) = 0.59e-1, (11, 1) = 200, (11, 2) = 6.26332, (11, 3) = 0.38e-1, (12, 1) = 200, (12, 2) = 6.10814, (12, 3) = 0.39e-1, (13, 1) = 200, (13, 2) = 6.83857, (13, 3) = 0.25e-1}); avicel301_101_aero200 := Matrix(12, 3, {(1, 1) = 50, (1, 2) = 1.106, (1, 3) = .2597543205, (2, 1) = 50, (2, 2) = 1.06, (2, 3) = .2564849561, (3, 1) = 50, (3, 2) = 1.129, (3, 3) = .2552025392, (4, 1) = 100, (4, 2) = 2.865, (4, 3) = .1280363098, (5, 1) = 100, (5, 2) = 2.793, (5, 3) = .127659333, (6, 1) = 100, (6, 2) = 3.088, (6, 3) = .1347147061, (7, 1) = 150, (7, 2) = 4.216, (7, 3) = 0.802489497e-1, (8, 1) = 150, (8, 2) = 4.044, (8, 3) = 0.838493001e-1, (9, 1) = 150, (9, 2) = 4.071, (9, 3) = 0.855901289e-1, (10, 1) = 200, (10, 2) = 4.826, (10, 3) = 0.627298821e-1, (11, 1) = 200, (11, 2) = 4.924, (11, 3) = 0.614759445e-1, (12, 1) = 200, (12, 2) = 4.76, (12, 3) = 0.61001365e-1})

NULL

 

with(LinearAlgebra):

X[1] := Column(avicel102_aero200, 3):

X[2] := Column(avicel102_syloid, 3):

X[3] := Column(avicel301_101_aero200, 3):

S := Array(1 .. 3):

S[1] := ScatterPlot(X[1], Y[1], labels = [Porocity, Tensile*Strength], title = Compactability*of*Avicel102*with*Aerosil200):

with(plots):NULL

 

vSST := Array(1 .. 3):

tpfit := proc (x, y) options operator, arrow; Fit(a*exp(-k*p)+c, x, y, p, output = [leastsquaresfunction, residualsumofsquares, degreesoffreedom]) end proc:SST := proc (y) options operator, arrow; Variance(y)*(NumElems(y)-1) end proc:NULL

for i to 3 do fnTP[i] := tpfit(X[i], Y[i])[1] end do:

for i to 3 do fnPC[i] := Fit(c*p^2+b*p+a, P[i], X[i], p, output = [leastsquaresfunction, residualsumofsquares, degreesoffreedom])[1] end do:

NULL

for i to 3 do vSST[i] := SST(Y[i]) end do:

for i to 3 do pSST[i] := SST(X[i]) end do:

NULL

for i to 3 do vSSR[i] := tpfit(X[i], Y[i])[2] end do:

for i to 3 do Rsquare[i] := 1-vSSR[i]/vSST[i] end do:

NULL

``

s := Array(1 .. 3):

for i to 3 do s[i] := plot(fnTP[i], p = 0 .. .26, legend = typeset(fnTP[i], R^2, "= ", Rsquare[i])) end do

for i to 3 do ps[i] := plot(fnPC[i], p = 0 .. 200, legend = typeset(fnPC[i], R^2, "= ", pRsquare[i])) end do

G := Array(1 .. 3):

G[1] := [S[1], s[1]]:

pG := [[PS[1], ps[1]], [PS[2], ps[2]], [PS[3], ps[3]]]:NULL

NULL

Table 1: Compactability Curve

display(G[1])

 

NULL

display(G[2])

 

NULL

display(G[3])

 

NULL

NULL

NULL

Table 2: Compressibility Curve

display(pG[1])

 

NULL

display(pG[2])

 

NULL

display(pG[3])

 

NULL

``

ff := proc (x) options operator, arrow; unapply(x, p) end proc:

gtp := map(ff, fnTP):

gpc := map(ff, fnPC):

TS1 := proc (pressure) options operator, arrow; (`@`(gtp[1], gpc[1]))(pressure/Unit('MPa'))*Unit('MPa') end proc:

TS2 := proc (pressure) options operator, arrow; (`@`(gtp[2], gpc[2]))(pressure/Unit('MPa'))*Unit('MPa') end proc:

TS3 := proc (pressure) options operator, arrow; (`@`(gtp[3], gpc[2]))(pressure/Unit('MPa'))*Unit('MPa') end proc:

por1 := proc (p) options operator, arrow; gpc[1](p/Unit('MPa')) end proc:

(1)

por1(x*Unit('MPa'))

HFloat(0.36333333333333295)-HFloat(0.0036139999999999957)*x+HFloat(9.666666666666651e-6)*x^2

(2)

por1(x);

HFloat(0.36333333333333295)-HFloat(0.0036139999999999957)*x/Units:-Unit('MPa')+HFloat(9.666666666666651e-6)*x^2/Units:-Unit('MPa')^2

(3)

``

NULL

 

(4)

ts := 2/3*(10*P/(Pi*D^2*(2.84*t/D-.126*t/W+3.15*W/D+0.1e-1))):

Target Weight of Tablet, m__t:

m__t := 700*Unit('mg')

700*Units:-Unit('mg')

(5)

Tablet True Density:NULL

`&rho;__true1` := 1.8*Unit('g'/'cm'^3)

1800.0*Units:-Unit(('kg')/('m')^3)

(6)

Width of tablet w;

d := 7.747*Unit('mm')

7.747*Units:-Unit('mm')

(7)

Length of tablet, l:

l := 17.018*Unit('mm')

17.018*Units:-Unit('mm')

(8)

Cup Depth, h:

hh := 1.6764*Unit('mm')

1.6764*Units:-Unit('mm')

(9)

Cup Volume", `v__cup`"

v__cup := 119.789438*Unit('mm'^3)

119.789438*Units:-Unit(('mm')^3)

(10)

Die cross sectional area, v__die:

a__die := 118.9610524*Unit('mm'^2)

118.9610524*Units:-Unit(('mm')^2)

(11)

Equation to solve tablet thickness using tablet dimension and porocity:

Tablet bulk density:

`&rho;__bulk` := `&rho;__true`*sf

`&rho;__true`*sf

(12)

Tablet volume:``

V__tablet := 2*V__cup+A__die*(t-2*H)

2*V__cup+A__die*(t-2*H)

(13)

NULL

Tablet bulk Density:``

`&rho;__bulk` := m__tablet/V__tablet

m__tablet/(2*V__cup+A__die*(t-2*H))

(14)

NULL

eq1 := m__tablet/(2*V__cup+A__die*(t-2*H)) = `&rho;__true`*sf

m__tablet/(2*V__cup+A__die*(t-2*H)) = `&rho;__true`*sf

(15)

Function for thickness:

thickness := unapply(simplify(solve(eq1, t), size), sf, A__die, H, V__cup, `&rho;__true`, m__tablet)

proc (sf, A__die, H, V__cup, `&rho;__true`, m__tablet) options operator, arrow; (2*sf*(A__die*H-V__cup)*`&rho;__true`+m__tablet)/(A__die*sf*`&rho;__true`) end proc

(16)

simplify(thickness(1-por[1](100*Unit(MPa)), a__die, hh, v__cup, `&rho;__true1`, m__t))

HFloat(0.005719286791216391)*Units:-Unit('m')

(17)

t2 := proc (cc, A__die, H, V__cup, `&rho;__true`, m__tablet) options operator, arrow; simplify(thickness(1-cc, A__die, H, V__cup, `&rho;__true`, m__tablet)) end proc:

``

``

``

Tablet tensile strength:NULL

eq2 := `&sigma;__t` = ts

`&sigma;__t` = (20/3)*P/(Pi*D^2*(2.84*t/D-.126*t/W+3.15*W/D+0.1e-1))

(18)

Break force of tablet (N)

breakforce := unapply(subs(W = t-2*h, solve(eq2, P)), `&sigma;__t`, D, h, t)

proc (`&sigma;__t`, D, h, t) options operator, arrow; 0.9424777961e-3*`&sigma;__t`*D*(5.*D*(t-2*h)-63.*t*D+1575.*(t-2*h)^2+1420.*t*(t-2*h))/(t-2*h) end proc

(19)

 

kp := simplify(breakforce(TS[1](100*Unit('MPa')), d, hh, 0.5719e-2*Unit('m')))

HFloat(286.99924404612904)*Units:-Unit('N')

(20)

convert(kp, units, kilopond)

HFloat(29.265778226624693)*Units:-Unit('kilopond')

(21)

t2(por[1](100*Unit('MPa')), a__die, hh, v__cup, `&rho;__true1`, m__t)

HFloat(0.005719286791216391)*Units:-Unit('m')

(22)

``

hh

1.6764*Units:-Unit('mm')

(23)

simplify(breakforce(TS[1](100*Unit('MPa')), d, hh, t2(por[1](100*Unit('MPa')), a__die, hh, v__cup, `&rho;__true1`, m__t)))

HFloat(287.02451456724083)*Units:-Unit('N')

(24)

Encounter problem while chaning variable

 BF:= 
proc (`&sigma;__t`, D, p, A__die, hhh, V__cup, `&rho;__true`, m__tablet) options operator, arrow; breakforce(`&sigma;__f`, D, hhh, t2(p, A__die, hhh, V__cup, `&rho;__true`, m__tablet)) end proc:

BF(TS1(100*Unit('MPa')), d, por1(100*Unit('MPa')), a__die, hh, v__cup, `&rho;__true1`, m__t)

BF(HFloat(3.6712504621161846)*Units:-Unit('MPa'), 7.747*Units:-Unit('mm'), HFloat(0.09859999999999991), 118.9610524*Units:-Unit(('mm')^2), 1.6764*Units:-Unit('mm'), 119.789438*Units:-Unit(('mm')^3), 1420.00*Units:-Unit(('kg')/('m')^3), 667*Units:-Unit('mg'))

(25)

evalf(TS[1](100*Unit(MPa)))

HFloat(3.6712504621161846)*Units:-Unit('MPa')

(26)

plot(breakforce(TS1(x), d, hh, t2(por1(x), a__die, hh, v__cup, `&rho;__true1`, m__t)), x = Unit('MPa') .. 200*Unit('MPa'), useunits = true)

Error, (in Units:-Standard:-+) the units `1` and `1/MPa` have incompatible dimensions

 

plot(t2(por1(x), a__die, hh, v__cup, `&rho;__true1`, m__t), x = Unit('MPa') .. 200*Unit('MPa'), useunits = true)

Error, (in Units:-Standard:-+) the units `1` and `1/MPa` have incompatible dimensions

 

plot(evalf(por1(xx)), xx = 10 .. 200)

 

but por1 works fine on its own with units

por1(Units:-Standard:-`*`(200, Unit('MPa')))

HFloat(0.02719999999999989)

(27)

plot(evalf(por1(xx)), xx = 10 .. 200);

 

Unloading Units:-Standard

``

``

``

``

``

``

``

``

``

``

``

``

``

``

 

Fitting_worksheet.mw

I also used a lot for for loop in this worksheet, can anyone suggest another way of doing it? And I think I initiated many Array(1..3) that is of no use.  But if I do not initiate and do the following

A[1]:=a : 

A[2]:=b:

A[3]:=c:

A;

output: A

Only if I initiate A:=Array(1..3) and then define the element I can see the complete A array at the end.

 

Hi, i'm wondering if theres anything i can do printf and print and have the outputs on the same line. I want the string wihtout any quotations so i think i can only do printf to get this, but then i'm putting an entry out of an array after this. This is a small example out of my code, i would like the output to be all on one line:

The synchronising vector is (S[j-1]) The synchronising word is (X[j-1]) The length of the synchronising word is ...

 

if (sync=true) then 
printf("The Synchronising vector is"); print(S[j-1]);
printf("The sychronising word is");
print(X[j-1]);
printf("The length of the synchronising word is");
print(length(X[j-1]));
else printf("There is no synchronising word"); 
end if;

 At the moment its outputing each print on a new line.

Any help would be much appreciated, thanks.

 

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