필터 지우기
필터 지우기

problem about the scipt

조회 수: 4 (최근 30일)
Shi Yuhao
Shi Yuhao 2014년 4월 27일
편집: Andrew Newell 2014년 5월 5일
clear all
l = 25
E = 200*10^9
I = 350*10^-6
w = 6*10^3
x = input('enter length of the beam')
if (x>=0)&(x<= l/2),
y = -w*x/384*E*I *(16*x^3-24*l*x^2+9*l^3);
elseif
(x>=l/2)& (x<= l);
y = -w*x/384*E*I*(8*x^3-24*l*x^2+(17*l^2)*x-l^3)
end
Why I can not get the value of y? How to get it?
  댓글 수: 10
Shi Yuhao
Shi Yuhao 2014년 4월 28일
E is the modulus of elasticity. I is the area moment of inertia. l is the length of the beam. w is the constant distributed load. The equation is provided by the question. It asks me to use the loop to do the calculation. But I haven't got result of it.
Geoff Hayes
Geoff Hayes 2014년 4월 28일
What are you asked to loop over? There is no loop in your above code. As well, please verify your equation. Perhaps post it here and we can help make sure that you have coded it up (in MATLAB) correctly.

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

채택된 답변

Image Analyst
Image Analyst 2014년 4월 27일
y DOES get assigned. Verify by stepping through your code. If you don't know how to do that, see this: http://blogs.mathworks.com/videos/2012/07/03/debugging-in-matlab/ Also, the line that says
(x>=l/2)& (x<= l);
should probably have a % in front of it because it doesn't do anything and appears like it should be a comment.
  댓글 수: 5
Shi Yuhao
Shi Yuhao 2014년 4월 28일
I am sorry to write such a answer. I am new to the matlab and I am confused about it. The results seems it never stops. Maybe I misunderstand the question. The question asks me to do the calculation using loop. The equation is provided by the question. It gives the value of w,E,I,and l.
Image Analyst
Image Analyst 2014년 4월 28일
I'm really baffled as to how that can be true. Please start a new script and paste this code in there exactly . I mean exactly - nothing else but this code below:
clc; % Clear the command window.
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fprintf('Starting code...\n');
l = 25
E = 200*10^9
I = 350*10^-6
w = 6*10^3
x = input('enter length of the beam : ')
if (x>=0) && (x<= l/2)
fprintf(' Now entering the "if" block of code to set the first y...\n');
y = -w*x/384*E*I *(16*x^3-24*l*x^2+9*l^3)
else
fprintf(' Now entering the "if" block of code to set the first y...\n');
y = -w*x/384*E*I*(8*x^3-24*l*x^2+(17*l^2)*x-l^3)
end
fprintf('Code has ended!\n');
Now, copy and paste what you see in your command window. When I type in 0.5, I see the following:
Starting code...
l =
25
E =
200000000000
I =
0.00035
w =
6000
enter length of the beam : 0.5
x =
0.5
Now entering the "if" block of code to set the first y...
y =
-76823359375000
Code has ended!
What do you see in your command window? Anything? What does "doesn't stop" mean? Does it doe it over and over again forever? Does it just do absolutely nothing at all with nothing in the command window whatsoever? What do you see?

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by