Hello, I am trying to write my function as = t^3 / (3 + 3t) + 1. I cannot for the life of me get this to work. The range is from t = 0 to t = 2.
There seems to be an issue with the brackets. Can anyone help me with how to write this so it works? No matter how i arrange it with brackets it doesnt seem to give me the correct answer. t = 0 y = 1, t = 0.5 y = 1.027, t = 1 y = 1.16, t = 1.5 y = 1.45, t = 2 y = 1.8 is the results i should get.
Thanks
Edit - didnt mean to put in a line of code at the top.

 채택된 답변

Fangjun Jiang
Fangjun Jiang 2020년 3월 10일

0 개 추천

t=0:0.5:2
y=t.^3./(3+3*t)+1

댓글 수: 3

Fangjun Jiang
Fangjun Jiang 2020년 3월 10일
run "help arith" to see the help document
Andrew Mackintosh
Andrew Mackintosh 2020년 3월 10일
Thank you! Magic help! cant believe it was just the . in front of the / that was messing everything up!
Image Analyst
Image Analyst 2020년 3월 10일
That wasn't everything. As I said in my answer below you were also missing the dot before the caret, and missing a star between 3 and t.

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

추가 답변 (1개)

Image Analyst
Image Analyst 2020년 3월 10일

0 개 추천

Try this, using .^ and ./ :
fontSize = 24;
% The range is from t = 0 to t = 2.
t = linspace(0, 2, 1000); % 1000 points.
% Make t^3 / (3 + 3t) + 1.
y = t.^3 ./ (3 + 3*t) + 1
plot(t, y, 'b-', 'LineWidth', 2);
xlabel('t', 'FontSize', fontSize);
ylabel('y', 'FontSize', fontSize);
grid on;

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

2020년 3월 10일

댓글:

2020년 3월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by