Repository navigation
Expand file tree
/
Copy pathConstructData.m
More file actions
55 lines (54 loc) · 1.54 KB
/
Copy pathConstructData.m
File metadata and controls
55 lines (54 loc) · 1.54 KB
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
function Data = ConstructData(Data)
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
DataType=Data.Type;
if strcmpi(DataType,'Load Data')
filename=Data.filename;
DataOrient=Data.DataOrient;
xPoint=Data.xPoint;
yPoint=Data.yPoint;
else
xMin=Data.xMin;
xMax=Data.xMax;
numPoints=Data.numPoints;
xData=linspace(xMin,xMax,numPoints)';
Coef=Data.Coef;
end
%filename and DataOrient declared below so they are not required for other
%Data type entries
switch DataType
case 'Normal Scatter'
yData=Coef(1)+randn(length(xData),1)*Coef(2);
case 'Straight Line'
yData=Coef(1)*ones(length(xData),1)+Coef(2);
case 'Runge Function'
a=Coef(1);
b=Coef(2);
c=Coef(3);
TrueFunc=@(x) a./(b+c.*x.^2);
yData=TrueFunc(xData);
case 'First Order ODE'
yData=FirstOrderODE(Coef,xData);
case 'Harmonic ODE'
yData=HarmonicODE(Coef,xData);
case 'Load Data'
DataTemp=load(filename);
switch DataOrient
case 'column'
xData=DataTemp(:,xPoint);
yData=DataTemp(:,yPoint);
case 'row'
xData=DataTemp(xPoint,:);
yData=DataTemp(yPoint,:);
otherwise
fprintf(['Error!! Data orientation not recognized. Enter as'...
'row or column'])
keyboard
end
otherwise
fprintf('Error!! DataType not recognized')
keyboard
end
Data.x=xData;
Data.y=yData;
end