24小时热门版块排行榜    

查看: 802  |  回复: 2
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

tonifcty

金虫 (初入文坛)

[求助] 帮忙把下面matlab m文件写成mathematica程序

就是一个对应的找位置的小程序,但是本人不会mathematica,求指导,多谢
前面赋值的部分搞成输入那种
function [Plate,Col,Row]=findplace(x,y,z)
%x:row,y:column,z:slide
%microarray column and row to microplate column and row
%set parameter

i=8;%microplate row number
j=10;%microplate column number
Ne=5; %Number of needle
length=4.5e4;%length of microarry
width=2.0e4;%width of microarry
stepx=250;
stepy=250;

%calculate
R=fix(width/stepy);
C=fix(length/stepx);% Total numbers of rows and columns of microarray
subcolumn=fix(C/Ne); % numbers of columns for each needle array

array=ceil(y/subcolumn);
time=R*(y-1-(array-1)*subcolumn)+x+(z-1)*R*subcolumn;% the number of spots
Plate=ceil(time/(i*j/Ne));

a=rem(time,(i*j/Ne));
if a==0
    Row=i;
    Col=array+1+Ne;
elseif a<=i
    Row=a;
    Col=array+1;
else
    Row=a-i;
    Col=array+1+Ne;
end
回复此楼
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

xzczd

木虫 (小有名气)

楼主是自暴自弃了吗……选了一个完全无关的答案。如果只是翻译一下是很容易的:

findplace[x_, y_, z_] :=
With[{i = 8, j = 10, Ne = 5, length = 4.5 10^4, width = 2.0 10^4, stepx = 250, stepy = 250},
  Module[{r, c, a, subcolumn, array, time, plate, row, col},
   r = IntegerPart@(width/stepy);
   c = IntegerPart@(length/stepx);
   subcolumn = IntegerPart@(c/Ne);
   array = Ceiling@(y/subcolumn);
   time = r*(y - 1 - (array - 1)*subcolumn) + x + (z - 1)*r*subcolumn;
   plate = Ceiling@(time/(i*j/Ne));
   a = Mod[time, (i*j/Ne)];
   Which[ a == 0, row = i; col = array + 1 + Ne, a <= i, row = a;
    col = array + 1, True, row = a - i; col = array + 1 + Ne]; {plate, col, row}]]
小木虫Mathematica版块已毁(当然原本也不咋的),建议大家前往百度贴吧或Stackexchange。
3楼2014-07-04 12:19:32
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 3 个回答

落叶撼秋风

新虫 (小有名气)

【答案】应助回帖

★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★ ★
感谢参与,应助指数 +1
tonifcty: 金币+50, ★★★★★最佳答案 2013-11-01 18:36:24
function [Plate,Col,Row]=findplace(x,y,z)
%x:row,y:column,z:slide
%microarray column and row to microplate column and row
%set parameter

i=8;%microplate row number
j=10;%microplate column number
Ne=5; %Number of needle
length=4.5e4;%length of microarry
width=2.0e4;%width of microarry
stepx=250;
stepy=250;

%calculate
R=fix(width/stepy);
C=fix(length/stepx);% Total numbers of rows and columns of microarray
subcolumn=fix(C/Ne); % numbers of columns for each needle array

array=ceil(y/subcolumn);
time=R*(y-1-(array-1)*subcolumn)+x+(z-1)*R*subcolumn;% the number of spots
Plate=ceil(time/(i*j/Ne));

a=rem(time,(i*j/Ne));
if a==0
    Row=i;
    Col=array+1+Ne;
elseif a<=i
    Row=a;
    Col=array+1;
else
    Row=a-i;
    Col=array+1+Ne;
end
2楼2013-11-01 18:28:46
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
信息提示
请填处理意见