Using condition in Function
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
F.O
am 15 Nov. 2017
Beantwortet: Walter Roberson
am 16 Nov. 2017
Hei. I have this script:
%% Problem 3 clear all
%a) %DATA for Nazca-Pacific o1=13.6*10^-7 l1=55.6 ph1=-90.1 %DATA for Pacific-Antarctica o2=8.7*10^-7 l2=-64.3 ph2=96 [omeganew,lambdanew,phinew] = geofun( o1,l1,ph1,o2,l2,ph2) %phinew1=phinew1-180
%b) %From Table 2.1 in Fowler Book We choose Africa-North America and Africa- %south America plate pairs because they have a common boundary %Data for Africa-South America SwA=3.1*10^-7 ; %Degree/yr latSA=62.5; %Degree longSA=-39.4; %Data for Africa-North America(The angular velocity is given for North %America relative to Africa and we get for Africa relative to North America %just by change the sign) NwA=2.4*10^-7; AwN=-2.4*10^-7; latAN=78.8; longAN=38.3; [SwN,latSN,longSN] = geofun( SwA,latSA,longSA,AwN,latAN,longAN)
and this function
function [ omeganew,lambdanew,phinew] = geofun( o1,l1,ph1,o2,l2,ph2) %Using known rotation vector data from two pairs of plates to find the %‘unknown’ rotation vector data of another pair of plates (using Table 2.1) 2.1
x=o1*cosd(l1)*cosd(ph1)+o2*cosd(l2)*cosd(ph2) y=o1*cosd(l1)*sind(ph1)+o2*cosd(l2)*sind(ph2) z=o1*sind(l1)+o2*sind(l2) omeganew=sqrt(x^2+y^2+z^2) lambdanew=asind(z/omeganew) phinew=atand(y/x) end
How I will add a condition to the function or where I should put the condition
the condition is If x> 0 then -90<phinew<90 otherwise we subtract 180 from phinew and ifx<0 then the absoloute value of phinew should be greater than 90 otherwise we subtract 180 from phinew
1 Kommentar
Image Analyst
am 16 Nov. 2017
Try this http://www.mathworks.com/matlabcentral/answers/13205#answer_18099 so your post won't go into the spam quarantine next time. I've rescued your post this time.
Akzeptierte Antwort
Walter Roberson
am 16 Nov. 2017
Use atan2d(y, x) instead of atand(y/x) and you will probably not need to make any angle correction.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu 3-D Scene Control finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!