Trouble Solving for Variables Using 3 Separate Numbers
情報
この質問は閉じられています。 編集または回答するには再度開いてください。
古いコメントを表示
Assignment is "write a MATLAB script file (Lab07p2.m) that plots the tensions for Theta=5,10,...85 deg, LAC=6 ft, LAB=3,6,9 ft, and W=2000 lb.
So heres my code: it works perfectly with one number in for LAB but when I plug in 3 it doesn't. Not sure how to fix this and/or if there is a simple way to do so.
CODE::
lab = (3 6 9); {PROBLEM AREA} %ft
lac = 6; %ft
W = 2000; %lbs
theta = (5:5:85); %degrees
phi = atand(lab.*sind(theta) ./ (lac-lab.*cosd(theta))); %degrees
Lbc = lab.*sind(theta) ./ sind(phi); %ft
Tab = (W.*cosd(phi)) ./ ((sind(theta)+ cosd(theta)).*(sind(phi)));
Tbc = (Tab.*cosd(theta)) ./ (cosd(phi));
T = max(Tab, Tbc);
plot(Tab, Tbc);
Any advice/fixes will be greatly appreciated!! Thank YOU :)
0 件のコメント
回答 (1 件)
Hi,
vectors are defined by square brackets. Then additionally use the colon operator ':' since your result gets a matrix:
lab = [1 2 4]; % {PROBLEM AREA} %ft
lac = 6; %ft
W = 2000; %lbs
theta = (5:5:85); %degrees
phi = atand(lab(:).*sind(theta) ./ (lac-lab(:).*cosd(theta))); %degrees
Lbc = lab(:).*sind(theta) ./ sind(phi); %ft
Tab = (W.*cosd(phi)) ./ ((sind(theta)+ cosd(theta)).*(sind(phi)));
Tbc = (Tab.*cosd(theta)) ./ (cosd(phi));
T = max(Tab, Tbc);
plot(Tab', Tbc');
Best regards
Stephan
0 件のコメント
この質問は閉じられています。
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!