Home > eeg > egis > phantom > tp2xyz.m

# tp2xyz

## SYNOPSIS

function [x,y,z,v] = tp2xyz(tp,dim,vtp)

## CROSS-REFERENCE INFORMATION

This function calls:
This function is called by:

## SOURCE CODE

```0001 function [x,y,z,v] = tp2xyz(tp,dim,vtp)
0002 if dim == 1
0003     x = zeros(size(tp,1),1);
0004     y = zeros(size(tp,1),1);
0005     z = zeros(size(tp,1),1);
0006     v = zeros(size(tp,1),1);
0007     az = tp(:,2);
0008     el = pi/2*ones(size(tp,1),1) - tp(:,1);
0009     r = 9*ones(size(tp,1),1);
0010     [x,y,z] = sph2cart(az,el,r);
0011     if nargin == 3
0012     v = vtp;
0013         end;
0014 elseif dim == 2
0015     x = zeros(sqrt(size(tp,1)),sqrt(size(tp,1)));
0016     y = zeros(sqrt(size(tp,1)),sqrt(size(tp,1)));
0017     z = zeros(sqrt(size(tp,1)),sqrt(size(tp,1)));
0018     v = zeros(sqrt(size(tp,1)),sqrt(size(tp,1)));
0019     az = tp(:,2);
0020     el = pi/2*ones(size(tp,1),1) - tp(:,1);
0021     r = 9*ones(size(tp,1),1);
0022     [xt,yt,zt] = sph2cart(az,el,r);
0023     ic = 1;
0024     for i = 1:size(x,1)
0025         for j = 1:size(x,2)
0026             x(i,j) = xt(ic);
0027             y(i,j) = yt(ic);
0028             z(i,j) = zt(ic);
0029             ic = ic +1;
0030             if nargin == 3
0031             v(i,j) = vtp(ic);
0032             end;
0033         end;
0034     end;
0035 end;```

Generated on Wed 22-May-2019 04:00:51 by m2html © 2003