Invalid expression please fix :(

조회 수: 6 (최근 30일)
habib
habib 2023년 9월 14일
답변: Image Analyst 2023년 9월 17일
%given data
a = 45; % Angle in degrees
P = 100; % Load in Newtons
h = 1.0; % Truss height in meters
% Calculate horizontal and vertical components of the load
P_horizontal = P * cosd(a);
P_vertical = P * sind(a);
% Calculate reactions at supports
G_x = P_horizontal;
G_y = P_vertical;
% Calculate forces in members
BC_y = G_y;
BC_x = 0;
CL_y = BC_y;
CK_y = 0;
CD_x = 0;
EF_x = 0;
EF_y = 0;
KL_x = 0;
KL_y = 0;
% Display results
fprintf('Forces in Members:\n');
Forces in Members:
fprintf('BC: %.2f N (compression)\n', BC_y);
BC: 70.71 N (compression)
fprintf('CL: %.2f N (tension)\n', CL_y);
CL: 70.71 N (tension)
fprintf('CK: Zero force member\n');
CK: Zero force member
fprintf('CD: %.2f N (tension)\n', CD_x);
CD: 0.00 N (tension)
fprintf('KL: Zero force member\n');
KL: Zero force member
fprintf('EF: Zero force member\n');
EF: Zero force member
  댓글 수: 12
habib
habib 2023년 9월 17일
ive tried it all still doesnt run, ive given up if you can send screenshots of code running that would be helpful
Walter Roberson
Walter Roberson 2023년 9월 17일
One of the moderators edited your post to format your code and run it here on MATLAB Answers. Because of that, your Question is now effectively a screen capture of the output of the code as if you had run it as a Livescript.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2023년 9월 17일
"can send screenshots of code running that would be helpful".
It runs fine in r2023a and r2023b (see below). Now it's your turn to attach screenshots.

카테고리

Help CenterFile Exchange에서 Text Analytics Toolbox에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by