Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
problem with equation plotting

Subject: problem with equation plotting

From: Tiera-Brandy

Date: 20 Oct, 2011 22:47:09

Message: 1 of 4

Ok the following is the code I've written to compare some observed data with calculated data, the point of the exercise was to adjust two variables to make the plot of the calculated data match the observed data. However I know my two variables are correct but the graphs still don't match and I think it has to do with my "a" and "AMP" equations, I just don't see where I went wrong.
%PART 1.3
   %importing observed data set and assigning values for x and y
    x = assig1(:,1);
    y = assig1(:,2);
    plot(x,y)
    hold on
%Rewriting the code
%Known variables for equation
    theta = pi/2;
    I = 1.117;
    A = 0;
    T = 47500;
    x = -100:20:100;
    h = 5;
%Adjustable variables
    deltaK = 0.004;
    d = 17.4;
%Equations
AMP = 2*deltaK*T*(sin(I)/sin(atan(tan(I)/cos(A)))^2*sin(theta));
a = 2*atan(tan(I)/cos(A))-theta;
%Main Equation
deltaT = AMP*(sin(a)*(atan(x + d / h) - atan(x - d / h))-(cos(a)/2).*log(((x + d).^2 + h^2) ./ ((x - d).^2 + h^2)));
plot(x,deltaT,'r-')

Subject: problem with equation plotting

From: Claudio

Date: 21 Oct, 2011 07:44:10

Message: 2 of 4


"Tiera-Brandy" wrote in message <j7q8dd$6o1$1@newscl01ah.mathworks.com>...
> Ok the following is the code I've written to compare some observed data with calculated data, the point of the exercise was to adjust two variables to make the plot of the calculated data match the observed data. However I know my two variables are correct but the graphs still don't match and I think it has to do with my "a" and "AMP" equations, I just don't see where I went wrong.
> %PART 1.3
> %importing observed data set and assigning values for x and y
> x = assig1(:,1);
> y = assig1(:,2);
> plot(x,y)
> hold on
> %Rewriting the code
> %Known variables for equation
> theta = pi/2;
> I = 1.117;
> A = 0;
> T = 47500;
> x = -100:20:100;
> h = 5;
> %Adjustable variables
> deltaK = 0.004;
> d = 17.4;
> %Equations
> AMP = 2*deltaK*T*(sin(I)/sin(atan(tan(I)/cos(A)))^2*sin(theta));
> a = 2*atan(tan(I)/cos(A))-theta;
> %Main Equation
> deltaT = AMP*(sin(a)*(atan(x + d / h) - atan(x - d / h))-(cos(a)/2).*log(((x + d).^2 + h^2) ./ ((x - d).^2 + h^2)));
> plot(x,deltaT,'r-')

============================

Hi Tiera-Brandy,

It's not easy to answer you without knowing what is in "assig1" and "assig2", and what your equations model.
However, some features of deltaT are missing in the plot because of the too few points in x. Try changing
 x = -100:20:100;
to
 x = -100:1:100;

Claudio

Subject: problem with equation plotting

From: Tiera-Brandy

Date: 21 Oct, 2011 10:00:12

Message: 3 of 4

> Hi Tiera-Brandy,
>
> It's not easy to answer you without knowing what is in "assig1" and "assig2", and what your equations model.
> However, some features of deltaT are missing in the plot because of the too few points in x. Try changing
> x = -100:20:100;
> to
> x = -100:1:100;
>
> Claudio

Well assig is basically two columns of numbers; assig1 one refers to column 1 assig2 refers to column 2. I'll post the list so you guys can recreate the graph. The numbers/graphs are the total intensity anomaly observed along a N-S profile over an E-W striking vertical dipping dike.
-100 114.339700000000
-99 125.313600000000
-98 131.192800000000
-97 116.577100000000
-96 127.308100000000
-95 106.919700000000
-94 122.443900000000
-93 104.933800000000
-92 110.595900000000
-91 118.525300000000
-90 135.726700000000
-89 105.974700000000
-88 135.162300000000
-87 110.334300000000
-86 139.947800000000
-85 135.577300000000
-84 148.682700000000
-83 128.284400000000
-82 148.415700000000
-81 155.636700000000
-80 130.359000000000
-79 147.286500000000
-78 136.710500000000
-77 149.787000000000
-76 142.112100000000
-75 168.464600000000
-74 135.095500000000
-73 141.749500000000
-72 146.260500000000
-71 145.964800000000
-70 165.627600000000
-69 158.818700000000
-68 163.123400000000
-67 167.662100000000
-66 180.674500000000
-65 184.642200000000
-64 179.533900000000
-63 191.610800000000
-62 171.774800000000
-61 167.862200000000
-60 209.587300000000
-59 192.975600000000
-58 214.676900000000
-57 189.985500000000
-56 186.573600000000
-55 227.703000000000
-54 197.228900000000
-53 238.696700000000
-52 216.897500000000
-51 217.952000000000
-50 233.225700000000
-49 224.723600000000
-48 230.001500000000
-47 247.046500000000
-46 273.014500000000
-45 276.612100000000
-44 285.213200000000
-43 298.414300000000
-42 303.848900000000
-41 292.002200000000
-40 288.149100000000
-39 321.230100000000
-38 329.315600000000
-37 317.430800000000
-36 330.859600000000
-35 354.404600000000
-34 355.746600000000
-33 379.563700000000
-32 413.029300000000
-31 417.742700000000
-30 453.903500000000
-29 473.222600000000
-28 481.442900000000
-27 513.722600000000
-26 547.536000000000
-25 572.478300000000
-24 603.030200000000
-23 650.466700000000
-22 696.973400000000
-21 745.082700000000
-20 800.115200000000
-19 869.287700000000
-18 891.044000000000
-17 917.294800000000
-16 966.803900000000
-15 951.991100000000
-14 974.845900000000
-13 942.074600000000
-12 941.910800000000
-11 921.966200000000
-10 905.505200000000
-9 883.165800000000
-8 848.686400000000
-7 804.093200000000
-6 773.373900000000
-5 748.054900000000
-4 746.136900000000
-3 683.117800000000
-2 649.818400000000
-1 625.212100000000
0 623.056300000000
1 577.599600000000
2 531.624300000000
3 496.624300000000
4 481.577700000000
5 443.035400000000
6 388.358900000000
7 355.580900000000
8 306.683300000000
9 276.257100000000
10 229.378400000000
11 150.207700000000
12 95.3997000000000
13 26.9215000000000
14 -5.93500000000000
15 -77.6337000000000
16 -142.920300000000
17 -222.459600000000
18 -264.683100000000
19 -333.520400000000
20 -328.534900000000
21 -341.401000000000
22 -368.158100000000
23 -376.957100000000
24 -354.830200000000
25 -343.410600000000
26 -342.309800000000
27 -328.907500000000
28 -332.323600000000
29 -339.517300000000
30 -319.859400000000
31 -290.399200000000
32 -293.863000000000
33 -272.592800000000
34 -282.942300000000
35 -272.950300000000
36 -288.678400000000
37 -274.631000000000
38 -255.269600000000
39 -265.571800000000
40 -229.506800000000
41 -234.063800000000
42 -250.251300000000
43 -244.772500000000
44 -231.741500000000
45 -223.256400000000
46 -207.766400000000
47 -227.165300000000
48 -190.572200000000
49 -210.820200000000
50 -203.621500000000
51 -207.396100000000
52 -186.443400000000
53 -197.074700000000
54 -197.181200000000
55 -173.476200000000
56 -179.582600000000
57 -193.675400000000
58 -173.599100000000
59 -162.054200000000
60 -170.915900000000
61 -157.947400000000
62 -171.248500000000
63 -155.087900000000
64 -155.843500000000
65 -161.627900000000
66 -170.503800000000
67 -142.525600000000
68 -160.810500000000
69 -154.803600000000
70 -161.406900000000
71 -122.570700000000
72 -133.674900000000
73 -144.062800000000
74 -127.021700000000
75 -123.228300000000
76 -140.754100000000
77 -135.630900000000
78 -132.652800000000
79 -133.866200000000
80 -107.809500000000
81 -118.354300000000
82 -120.987800000000
83 -111.136200000000
84 -128.700700000000
85 -132.977300000000
86 -108.652300000000
87 -125.326100000000
88 -100.315500000000
89 -127.022900000000
90 -97.8741000000000
91 -114.660600000000
92 -104.606100000000
93 -121.082500000000
94 -107.839300000000
95 -106.171000000000
96 -120.590600000000
97 -98.5775000000000
98 -101.393800000000
99 -120.941900000000
100 -83.0971000000000

Subject: problem with equation plotting

From: HB

Date: 21 Oct, 2011 12:48:35

Message: 4 of 4

On 21 Okt., 09:44, "Claudio " <cverg...@gmail.com> wrote:
> "Tiera-Brandy" wrote in message <j7q8dd$6o...@newscl01ah.mathworks.com>...
> > Ok the following is the code I've written to compare some observed data with calculated data, the point of the exercise was to adjust two variables to make the plot of the calculated data match the observed data. However I know my two variables are correct but the graphs still don't match and I think it has to do with my "a" and "AMP" equations, I just don't see where I went wrong.
> > %PART 1.3
> >    %importing observed data set and assigning values for x and y
> >     x = assig1(:,1);
> >     y = assig1(:,2);
> >     plot(x,y)
> >     hold on
> > %Rewriting the code
> > %Known variables for equation
> >     theta = pi/2;
> >     I = 1.117;
> >     A = 0;
> >     T = 47500;
> >     x = -100:20:100;
> >     h = 5;
> > %Adjustable variables
> >     deltaK = 0.004;
> >     d = 17.4;
> > %Equations
> > AMP = 2*deltaK*T*(sin(I)/sin(atan(tan(I)/cos(A)))^2*sin(theta));  
> > a = 2*atan(tan(I)/cos(A))-theta;
> > %Main Equation
> > deltaT = AMP*(sin(a)*(atan(x + d / h) - atan(x - d / h))-(cos(a)/2).*log(((x + d).^2 + h^2) ./ ((x - d).^2 + h^2)));
> > plot(x,deltaT,'r-')
>
> ============================
>
> Hi Tiera-Brandy,
>
> It's not easy to answer you without knowing what is in "assig1" and "assig2", and what your equations model.
> However, some features of deltaT are missing in the plot because of the too few points in x. Try changing
>  x = -100:20:100;
> to
>  x = -100:1:100;
>
> Claudio

Hi,
are you aware that you are overwriting x? Is this intentional?

x = assig1(:,1);
plot(x,y)
hold on
...
x = -100:20:100;
...
plot(x,deltaT,'r-')

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us