-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewberg and Murphy Walkthrough.m
61 lines (42 loc) · 2.25 KB
/
Newberg and Murphy Walkthrough.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
(* ::Package:: *)
(************************************************************************)
(* This file was generated automatically by the Mathematica front end. *)
(* It contains Initialization cells from a Notebook file, which *)
(* typically will have the same name as this file except ending in *)
(* ".nb" instead of ".m". *)
(* *)
(* This file is intended to be loaded into the Mathematica kernel using *)
(* the package loading commands Get or Needs. Doing so is equivalent *)
(* to using the Evaluate Initialization Cells menu command in the front *)
(* end. *)
(* *)
(* DO NOT EDIT THIS FILE. This entire file is regenerated *)
(* automatically each time the parent Notebook file is saved in the *)
(* Mathematica front end. Any changes you make to this file will be *)
(* overwritten. *)
(************************************************************************)
(* ::Code::Plain:: *)
processData
setup(dataroot)
options=setOptions(inputs)
outputs=prepareData(method,params)
handleData(data,params)
processImage(readpath,writepath,params)
H=findH(V,W)
[W,H]=findWH(V,inputs)
[J,ma]=reconIH(I,H,IDX,sc)
You can easily build similar functionality yourself with Mathematica's Position[]. E.g. given a list of numbers you could do the following:
In[1] := A = {1, 5, 2, 3, 7, 3, 2, 8, 6, 5, 9, 2, 1};
In[2] := {#, Flatten[Position[A, #]]} & /@ Union[A]
OUT[2]:= {{1, {1, 13}}, {2, {3, 7, 12}}, {3, {4, 6}}, {5, {2, 10}}, {6, {9}}, {7, {5}}, {8, {8}}, {9, {11}}}
to get the list of unique elements and the indices of where they appear in the original list. To replicate exactly the functionality of Matlab's Unique (), especially
[b,m,n] = unique (A)
you need
b = Union[A];
m = Last[Position[A, #]] & /@ b // Flatten;
n = Position[b, #] & /@ A // Flatten;
which now provide the desired behavior
In[1] := A[[#]] & /@ m == b
Out[1]:= True
In[2] := b[[#]] & /@ n == A
Out[2]:= True