Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello I am trying to figure out why my code won\'t work for this. The error says

ID: 3541470 • Letter: H

Question

Hello I am trying to figure out why my code won't work for this. The error says that V and h are not the same length for the plot which they are! Could someone help me out with this? Thanks guys! My code is down below:


% 2.23 Problem

%Brackets for output, () for the inputs

function[V]=cylinder(r,L)

h=1:.1:L;

%The function file has outputs and inputs, the inputs are the values you

%want inputted in and the outputs are what you get out of it.

for P=1:1:length(h);

h=1:.1:L;

V(P)=(r.^2*acos((r-h(P))/(r))-(r-h(P))*sqrt(2*r*(h(P))-(h(P)).^2))*(L);

%an end is needed for every function file

% * is for multiplication, sqrt is square root

plot(V,h)

end

end

Explanation / Answer

I think you are doing matrix multiplication in the term v (p)=r.^2

So first define the size of matrix r and then equate the size of both v and r then only it will be plotted

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote