I would like to see my answer as X= , not as ans=
1 view (last 30 days)
Show older comments
Ogeday Ormanlioglu
on 2 Nov 2015
Commented: Image Analyst
on 2 Nov 2015
function[H,S]=silindir2(r,R,h,Vcap,V,Q)%H:Yükseklik S=Yüzey Alanı
r=9.15;R=13.7;V=5665.37
Q=acosd((sqrt((R^2)-(r^2))/R))
h=(R*(1-cos(Q*pi/180)))
Vcap=((1/3)*pi*(h^2)*(3*R-h))
H=(V-Vcap)/(pi*(r^2)); round(H)
S=(2*pi*r*H)+(2*pi*R*h); round(S)
end
When I run this I see:
ans =
20
ans =
1434
ans =
19.7021
But I want to see:
H=
20
S=
1434
I have been trying so long and i am just a beginner on matlab so please help :(
0 Comments
Accepted Answer
Image Analyst
on 2 Nov 2015
If you want to round H and S, use round on the right hand side
H = round((V-Vcap)/(pi*(r^2)))
S = round((2*pi*r*H)+(2*pi*R*h))
or else do it in two steps
H = (V-Vcap)/(pi*(r^2));
H = round(H)
S = (2*pi*r*H)+(2*pi*R*h);
S = round(S)
When you used round() and didn't assign the output to anything, that's when it just reported the output to the command window as "ans".
4 Comments
Image Analyst
on 2 Nov 2015
I don't know where that extra ans comes from. There is no code after the S=round(S) so there should be no ans popping up. There must be some code elsewhere that you have not shown - perhaps in the code that called silindir2(), just after you called it.
More Answers (0)
See Also
Categories
Find more on Tables in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!