Subjects
PRICING
COURSES
SIGN IN
Start Free Trial
Krishna S.
Teacher at an NGO, Student at BITS Pilani
Tutor Satisfaction Guarantee
MATLAB
TutorMe
Question:

Convolute two identical rectangular pulses? 1- Write a function rect(t) 2- Write a program to find two convolution of two identical rectangular pulses which are defined in the interval [-0.5 ,0.5 ] 3- plot both input and output

Krishna S.
Answer:

The following is code for the above question, comments are included for better understanding of question. function [ ] = task1aks( ) %function for rectangle function [ n ] = rectangle( t ) n=zeros(1,size(t,2)); for i=1:length(t) n(i)=0; if (t(i)>=-0.5) && (t(i)<=0.5) n(i)=1; end end end %initial values fs=100; t=-5:1/fs:5; x=rectangle(t); %convoluting things y=conv(x,x,'same')/fs; figure subplot(2,1,1); plot(t,x); title('Input_value'); subplot(2,1,2); plot(t,y); title('Output_value'); end

Java Programming
TutorMe
Question:

how to find out the middle element in a linked list in a single pass(in one loop through the list)?

Krishna S.
Answer:

The following is the code for above, comments are included in code for better understanding of the solution. /** * Java program to find middle element of linked list in one pass. * In order to find middle element of linked list we need to find length first * but since we can only traverse linked list one time, we will use two pointers * one which we will increment on each iteration while other which will be * increased every second iteration. so when first pointer will point to the * last of linked list, second will be pointing to the middle element of linked list */ public class LinkedListTest { public static void main(String args[]) { //creating LinkedList with 5 elements including head LinkedList linkedList = new LinkedList(); LinkedList.Node head = linkedList.head(); linkedList.add( new LinkedList.Node("1")); linkedList.add( new LinkedList.Node("2")); linkedList.add( new LinkedList.Node("3")); linkedList.add( new LinkedList.Node("4")); //finding middle element of LinkedList in single pass LinkedList.Node current = head; int length = 0; LinkedList.Node middle = head; while(current.next() != null){ length++; if(length%2 ==0){ middle = middle.next(); } current = current.next(); } if(length%2 == 1){ middle = middle.next(); } System.out.println("length of LinkedList: " + length); System.out.println("middle element of LinkedList : " + middle); } } class LinkedList{ private Node head; private Node tail; public LinkedList(){ this.head = new Node("head"); tail = head; } public Node head(){ return head; } public void add(Node node){ tail.next = node; tail = node; } public static class Node{ private Node next; private String data; public Node(String data){ this.data = data; } public String data() { return data; } public void setData(String data) { this.data = data; } public Node next() { return next; } public void setNext(Node next) { this.next = next; } public String toString(){ return this.data; } } }

Electrical Engineering
TutorMe
Question:

Why is only sine wave used to represent electrical waves in equations, not square or cosineor other forms of waves?

Krishna S.
Answer:

It is not by choice that we use sine wave as the standard form. It is also not because sine wave has a maximum minimum and as such a large rms value. Rms value for cosine and ramp waves is also same, but we don't use them, because in the power generation, emf induced produces current in sine wave form only.It is the simplest way we can produce current.

Send a message explaining your
needs and Krishna will reply soon.
Contact Krishna
Ready now? Request a lesson.
Start Session
FAQs
What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Session" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.