Which of the following pieces of code plots the function f(x) = sin(x)*sin(x) + x/(x - 3.97/tan(x)) over the range [-3:3]? [Note: You may use Scilab to answer this question.]1. >function g = testfunction(x) g = sin(x) .* sin(x) + x ./ (x -3.97 ./ tan(x) ) endfunction>xdat= linspace(-3 , 3 , 0.1); ydat = testfunction(xdat); plot xdat , ydat 2. >function g = testfunction(x) g = sin(x) * sin(x) + x / (x -3.97 / tan(x) ) endfunction xdat= linspace(-3 , 3 , 0.1); ydat = testfunction(xdat); plot xdat , ydat 3. >function g = testfunction(x) g = sin(x) * sin(x) + x / (x -3.97 / tan(x) ) endfunction for x= -3, 3, 0.1 xdat = x; ydat = testfunction(xdat); plot ydat, xdat end

🎲 Try a Random Question  |  Total Questions in Quiz: 64  |  🧠 Study this quiz with Flashcards
This question is part of a full practice quiz:
ME101: Final Exam - Introduction to Mechanical Engineering — practice the complete quiz, review flashcards, or try a random question.

MCQs on the basics of Mechanical Engineering.


Which of the following pieces of code plots the function f(x) = sin(x)*sin(x) + x/(x - 3.97/tan(x)) over the range [-3:3]? [Note: You may use Scilab to answer this question.]<br>1. >function g = testfunction(x)<br> g = sin(x) .* sin(x) + x ./ (x -3.97 ./ tan(x) )<br> endfunction<br>>xdat= linspace(-3 , 3 , 0.1);<br> ydat = testfunction(xdat);<br> plot xdat , ydat <br>2. >function g = testfunction(x)<br> g = sin(x) * sin(x) + x / (x -3.97 / tan(x) )<br> endfunction<br/><br> xdat= linspace(-3 , 3 , 0.1);<br> ydat = testfunction(xdat);<br> plot xdat , ydat <br/><br/>3. >function g = testfunction(x)<br> g = sin(x) * sin(x) + x / (x -3.97 / tan(x) )<br> endfunction<br/><br> for x= -3, 3, 0.1<br> xdat = x;<br> ydat = testfunction(xdat);<br> plot ydat, xdat<br> end<br/>