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

NEED HELP FOR MATLAB SCRIPT AC Power from a wall socket The script needs to crea

ID: 3813049 • Letter: N

Question

NEED HELP FOR MATLAB SCRIPT

AC Power from a wall socket

The script needs to create 5 periods of a 60 Hz sinusoid, with an amplitude 120 Vrms, and have about 100 points per period.

Transformer

The script should them simulate the noisy sinusoid passing through a step down transformer. The turns ratio (N) should vary, and come from the user of the program being asked to enter a value between 2 and 20.

Rectifier

Ask the user whether they wish to pass the waveform through a full or half wave rectifier. Write one function that accepts the waveform and returns a half wave rectified waveform. Create another function that accepts a waveform and returns a full wave rectified. The script should call the correct function.

RC Filter

After the waveform is rectified, it then passes through a parallel RC circuit. Approximate the output waveform to be a decaying voltage where the voltage only decays for 1 period of the rectified waveform, then repeats. Assume a resistor of 1k, but prompt the user to enter the capacitor value. Write a function that takes a rectified waveform and returns a waveform that approximates an RC filter output.

Explanation / Answer

you will continue work with the film knowledge and store that knowledge in a very red-black tree. A red-black tree may be a self- leveling binary search tree. you may have to be compelled to balance the tree every time a brand new film node is additional or deleted. for every of {the films|the films|the flicks} within the film nodes within the movie tree, the subsequent data is kept: - IMDB ranking - Title - Year discharged - amount available - Node color
Use the Assignment10Movies.txt file. The name of the input data has to be handled as a command-line argument.
Insert all the flicks within the tree. once the user starts the program they'll pass it the name of the document that contains all film data. Your program has to handle that command-line argument, open the file, and browse all film knowledge within the file. From this knowledge, build the red-black tree ordered by film title. As movies ar additional to the tree, the red-black tree-balancing rule ought to be applied. All data regarding the film ought to even be enclosed within the film node within the tree. Note: the info ought to be additional to the tree within the order it's browse in. notice a film. once the user selects this selection from the menu, they ought to be prompted for the name of the film. If the film is found within the tree, show the film data. If the film isn't found, your program ought to show, “Movie not found.” this selection is comparable to rent film, however, you're not change the number. Rent a film. once the user selects this selection from the menu, they ought to be prompted for the name of the film. If the film is found within the tree, your program ought to update the number available property of the film and show the new data regarding the film. once the number is zero, the film ought to be deleted from the tree. once a film is deleted, the tree ought to be rebalanced. If the film isn't found, your program ought to show, “Movie not found.” Print the complete inventory. once the user selects this selection from the menu, your program ought to show all film titles and also the amount on the market in sorted order by title. See the lecture notes on in-order tree traversal for a lot of data. Delete a film. once the user selects this selection, they ought to be prompted for the title of the film to delete. Your code ought to then search the tree for that film, delete it if it’s found, then perform any necessary tree leveling to revive the red-black tree properties. If the film isn't found within the search method, print “Movie not found.” and don't decide to delete. Count movies within the tree. once the user selects this selection, your program ought to do associate degree in-order tree traversal and count the entire film nodes within the tree and print the worth. Count longest path. once the user selects this selection, your program has to verify the longest path from the foundation of the tree to rock bottom of tree, not together with empty nodes. Quit the program. once the user selects this selection, your program ought to delete the tree employing a post-order traversal.
The MovieTree.h file includes the example for the red-black tree category for this assignment. you would like to implement the category practicality in a very corresponding MovieTree.cpp file and Assignment10.cpp file. In MovieTree.h, you’ll notice that there's currently a node referred to as *nil. you may have to be compelled to assign memory for *nil within the MovieTree creator then use it altogether cases wherever you antecedently used NULL. Use the cout statements in Appendix A to line the order of the menu choices.
There is a file referred to as rbValid.cpp that you simply will use to examine that your tree- leveling rule is correct. This code checks that the red-black properties are restored to the tree.The MovieTree.h file includes a definition for the helper perform as a non-public methodology within the MovieTree category. you may have to be compelled to copy the code out of the rbValid.cpp file and incorporate it into MovieTree.cpp. decision the perform when adding a film to the tree to verify that your tree leveling works. this is often for debugging functions. going away the code in your program after you withstand COG shouldn't have an effect on your results. There ar further BST properties that don't seem to be being checked with this code – it's not checking that the values within the tree ar valid for all left and right sub-trees of a node.
There is additionally an internet site that shows visually the red-black leveling process: https://www.cs.usfca.edu/~galles/visualization/RedBlack.html. Note: this web site uses the utmost price within the left sub-tree because the replacement for a deletion with 2 kids. Your code has to use the minimum price within the right sub-tree.
Appendix A
Display menu cout << "======Main Menu======" << endl; cout << "1. notice a movie" << endl; cout << "2. Rent a movie" << endl; cout << "3. Print the inventory" << endl; cout << "4. Delete a movie" << endl; cout << "5. Count the movies" << endl; cout << "6. Count the longest path" << endl; cout << "7. Quit" << endl;
Find a film cout << "Enter title:" << endl;
Display found film data cout << "Movie Info:" << endl; cout << "===========" << endl; cout << "Ranking:" << foundMovie->ranking << endl; cout << "Title:" << foundMovie->title << endl; cout << "Year:" << foundMovie->year << endl; cout << "Quantity:" << foundMovie->quantity << endl;
If film not found cout << "Movie not found." << endl;
Rent a film //If film is available
cout << "Movie has been rented." << endl; cout << "Movie Info:" << endl; cout << "===========" << endl; cout << "Ranking:" << foundMovie->ranking << endl; cout << "Title:" << foundMovie->title << endl; cout << "Year:" << foundMovie->year << endl; cout << "Quantity:" << foundMovie->quantity << endl;
//If film not found in tree
cout << "Movie not found." << endl;
Print the inventory
//For all movies in tree
cout<<"Movie: "<<node->title<<" "<<node->quantity<<endl;
Count movies within the tree cout<<"Tree contains: "<<mt.countMovieNodes()<<" movies." << endl;
Longest path cout << "Longest Path: " << mt->countLongestPath() << endl;
Delete film cout << "Enter title:" << endl;
//If film not found in tree
cout << "Movie not found." << endl;
Delete all nodes within the tree
//For all movies in tree
cout<<"Deleting: "<<node->title<<endl;
Quit cout << "Goodbye!" << endl;
File I/O Error cout << "Could not open file ";

movieTree.h

#ifndef MOVIETREE_H
#define MOVIETREE_H

#include <string>

struct MovieNode;

MovieNode(int in_ranking, std::string in_title, int in_year, int in_quantity)
{
ranking = in_ranking;
title = in_title;
year = in_year;
amount = in_quantity;
// currently that we have a tendency to ar victimization cypher these NULL's ought to be overwritten in addMovieNode.
leftChild = NULL;
rightChild = NULL;
parent = NULL;
isRed = true;
}

};

class MovieTree
{

public:
MovieTree();
virtual ~MovieTree();
void printMovieInventory();
int countMovieNodes();
void deleteMovieNode(std::string title);
void addMovieNode(int ranking, std::string title, int releaseYear, int quantity);
void findMovie(std::string title);
void rentMovie(std::string title);
bool isValid();
int countLongestPath();

protected:

private:
void DeleteAll(MovieNode * node); //use this for the post-order traversal deletion of the tree
void printMovieInventory(MovieNode * node);
void rbAddFixup(MovieNode * node); // referred to as when insert to mend tree
void leftRotate(MovieNode * x); //rotate the tree left with x because the root of the rotation
void rbDelete(MovieNode * z); //delete a node. decision this from deleteMovieNode, the particular delete practicality happens here.
void rightRotate(MovieNode * x); //rotate the tree right with x because the root of the rotation
void rbDeleteFixup(MovieNode * node); //called when delete to mend the tree
void rbTransplant(MovieNode * u, MovieNode * v); //replace node u in tree with node v. Your resolution does not essentially have to be compelled to use this methodology
int rbValid(MovieNode * node); //check if the tree is valid, with node because the root of the tree
int countMovieNodes(MovieNode *node); //number of distinctive titles within the tree
int countLongestPath(MovieNode *node); //longest path from node to a leaf node within the tree
MovieNode* searchMovieTree(MovieNode * node, std::string title);
MovieNode *root;
MovieNode *nil;


};

#endif // MOVIETREE_H
helper perform goes in movieTree.cpp, Assignment10.cpp calls the functions outlined and created in movieTree
// Returns zero if the tree is invalid, otherwise returns the black node height.
int MovieTree::rbValid(MovieNode * node)
gonadotrophin = 0;
int rh = 0;

// If we have a tendency to ar at a zero node simply come one
if (node == nil)
return 1;

else
initial check for consecutive red links.
if (node->isRed)