MATLAB: Is the code only outputting one value instead of a vector loopvectors v_0=input('Enter the inital Velocity'); g=input('Enter Gravity Constant'); for t=0:0.05:(pi/2) r=(v_0^2/g)*sin(2*t)%#ok<NOPTS> end I am newer to matlab so I am unsure of why this is happening. Best Answer That is because you did not index ‘r’. Either do this (without the loop): t=0:0.05:(pi/2)r=(v_0^2/g)*sin(2*t);%#ok<NOPTS>or this (with the loop): t=0:0.05:(pi/2);for k = 1:numel(t) r(k)=(v_0^2/g)*sin(2*t(k))%#ok<NOPTS>endBoth will work, and both will produce the required result. Related SolutionsMATLAB: Hey guys please i need help with this. i am trying to have this function plot a graph of (a,r). The graph should be a curve but it gives me just a point. I don’t know what i did wrong! r = range_calculator % calling of the functionfunction r = range_calculatorg=9.9;a=0:0.05:pi/2;v=linspace(50,100,numel(a));for k=1:length(v) r(k)=(v(k).^2/g).*sin(2.*a(k));endplot(a,r,'--r*')grid ontitle('The initial velocity is v(k)')xticks(-0.4:0.2:1.8)yticks(0:50:800)xlabel('Cannon Angle')ylabel('Range,Meters')end MATLAB: I’m trying to find the integral of dv and all variables have been defined. I get the error message ‘Dot indexing is not supported for variables of this type.’ or if I remove the dot I get ‘Not enough input arguments.’ Please show me the error. than The erroir is that ‘dv’ must be defined as a function of one variable, and it is not defined as a function at all. What variable do you want to integrate it with respect to? Related QuestionProblem with For loopThe output is weirdAnalytic solution not possible. Can i solve with curve fitting
Best Answer