StudentShare
Contact Us
Sign In / Sign Up for FREE
Search
Go to advanced search...
Free

Matlab Programming in Solving Problems - Assignment Example

Cite this document
Summary
The author of the paper "Matlab Programming in Solving Problems" discusses the task tries to come up with a programming solution to the problem of combining resistors in a manner that would minimize the cost incurred in setting up the entire setup…
Download full paper File format: .doc, available for editing
GRAB THE BEST PAPER92.8% of users find it useful
Matlab Programming in Solving Problems
Read Text Preview

Extract of sample "Matlab Programming in Solving Problems"

? Matlab programing Introduction This task was conducted in a bid to find a solution to the problem of optimizing combination of E12 resistors in series. Resistors are components of electricity which obstruct the flow of electric current and in the process make the current do actual work like lighting, heating, producing sound, magnetism and the like. This task tries to come up with a programming solution to the problem of combining resistors in a manner that would minimize the cost incurred in setting up the entire set up. The task is to come up with a Matlab program which shall be able to lay out the most optimal mode of combining E12 resistors so as to form a desired value of resistance. It is to see to it that the resistors used are not unnecessarily too many and that the value of resistance that they form in combination are the closest to the desired value of resistance. Problem statement Resistors are measured in SI units known as ohms. In a bid to ease the process of manufacturing in bulk, the manufacturers of resistors usually do it in some standard set measures. These standard resistors are known as E12 resistors. They are the resistors with the values 10 ?; 12 ?; 15 ?; 18 ?; 22 ?; 27 ?; 33 ?; 39 ?; 47 ?; 56 ?; 68 ?; and 82 ? Designers of electrical components who which incorporate the use of resistors usually design for some arbitrary resistance values which shall best suit the requirements of the component under design. Given that resistors are manufactured in the 12 standard values, this implies that the designer shall have make an appropriate combination of a number of the standard resistors to form a value that is as close to the designed value of resistance as is practically possible. The combination should use as few resistors as possible to minimize costs and this calls for proper optimization. In this task, resistors are to be combined in series since resistors combining in series have the total resistance being the sum of the individual resistances of each one of the resistors connected in series. In this problem the designer desires to get optimization modes of combining resistors in series to get the following values of resistances:- 20 ?; 100 ?; 200 ?; 1k ?; 2k ?; 50k ?; 100k ?; 2m ?; 20M ?; 150M ?. Method The method employed in solving this problem takes advantage of the fact that each one of the E12 resistance values form a geometric series, they are all approximately 21% larger than the previous value. The method employed also takes advantage of the fact that for resistors in series, the total resistance is given by summing up the value of each of the individual resistances of the resistors connected in series. i.e, RT = R1 + R2 + R3 The method employed also targeted at making the program user friendly. It was to engage the user in a human like dialogue and hence be usable even by people who have no knowledge of programming. In this regard, the method employed was to write a program code that would ask for some two information from the user of the program. The first information to be inquired from the user is the desired value of resistance (target value). In this case the user would input one of the following as desired; 20 ?; 100 ?; 200 ?; 1k ?; 2k ?; 50k ?; 100k ?; 2m ?; 20M ?; 150M ?. The second information to be inquired from the user is the maximum number of resistors that can be combined. This was introduced in a bid to cut down on the cost of manufacturing. The method employed also involved the use of shorthand in which case, M, K and R were used instead of M ?; K ? and ? respectively. So as to make it possible for the universally accepted and used shorthand used by electrical engineers be input in the program by the users. Results and discussion The program so formed is user friendly and able to ask for the two values from the user, i.e. the value of resistance desired and the maximum number of resistors to be combined. The program is also able to accept values of input written in electrical engineers’ short hand for resistance. He program is able to list the values of the E12 resistances which are combined to form the desired resistance. The program is also able to display the error of the combination as a percentage from the desired value of resistance once it selects that best possible combination. The program is able to consider all the combinations that are possible from the E12 resistors when connected in series to form as close a value as the desired value. In the event that it is possible for the desired value to be achieved using some fewer resistors than those that the user of the program specified, the program is also able to display this combination. This program lives up to the expectations of the design. It is able to perform all the desired tasks and in turn able to solve the problem at hand. It poses no challenges to the user as it is very user friendly. It is also able to help the designer in cutting down on costs of manufacturing electrical components. Conclusion and recommendation The task has been very successful in its bid to come up with the most suitable Matlab program to solve the problem at hand. The task has put into consideration all the pertinent issues that surround the program and in turn come up with an all-round solution to the problem. It has come up with a program that is user finely and able to involve the designer in a dialogue that he or she understands be it that he understands coding or not. The program that has been developed is also able to generate modes of optimizing the series combination of the E12 resistors not just for the desired values of 20 ?; 100 ?; 200 ?; 1k ?; 2k ?; 50k ?; 100k ?; 2m ?; 20M ? and 150M ?, but for all the values that the designer desires with no limits. The program is a breakthrough in the design process and it makes it much easier and faster for designers to design any values of resistances as desired without bearing in mind how the combination of E12 resistors shall be done. It in a large way permits the bulk manufacturing of resistors within the constraints of the E12 standards since these standards can be combined in any fashion desired. It also allows for the repair and maintenance of the designed components as they use standard resistors that can be easily removed and replaced singly without affecting the rest of the electrical component. It is recommendable that in order to get the most optimal solution of combining the E12 resistors to form a desired resistance value or the value closest to it, the combination should incorporate the combination of the resistors also being in parallel. A combination that includes both parallel and series arrangement of the resistors gives the value of the total resistance that is the most extremely close to the desired value. This shall see to it that the displayed value of percentage error from the desired value is much more minimal than what is the case when only series combinations are considered. REFERENCES Coulson, L. (2009). MATLAB programming. Chandni Chowk, Delhi: Global Media. Kuncicky, D. C. (2004). Matlab programming. Upper Saddle River, N.J: Pearson Education. Equivalent resistances-6. (January 01, 1998). Appendix Source Codes clc %-- resistance INPUTS/calls --g resistance_call = input('What is the resistance wanting to be achieved?: ','s'); thousand_set = '[kK]'; million_set = '[mM]'; r_set = 'rR'; var = 'kKmM0123456789.'; non_r = []; non_l = []; thousd = '.*1000'; mill = '.*1000000'; digits = '0123456789.'; for count = 1 : length(resistance_call); x = resistance_call(count); if strfind(r_set, x); else non_r = [non_r count]; end; end resistance_array = ([resistance_call(non_r)]); resistance_array_call_final = str2num(resistance_array); for count2 = 1:length(resistance_array); x = resistance_array(count2); if strfind(var, x) else disp('ERROR:2 (refer to manual)'); return; end end end_count = 0; for count3 = 1:length(resistance_array); x = resistance_array(count3); if strfind(thousand_set, x) if end_count == 1 disp('ERROR:3 (refer to manual)'); return; elseif length(resistance_array) == count3 resistance_array = regexprep(resistance_array, thousand_set, '.*1000', 'ignorecase'); resistance_array_call_final = str2num(resistance_array); end_count = end_count + 1; elseif length(resistance_array) ~= count3 temp_array = regexprep(resistance_array, thousand_set, '.', 'ignorecase'); temp2_array = str2num(temp_array); resistance_array_call_final = temp2_array.*1000; end_count = end_count + 1; end elseif strfind(million_set, x) if end_count == 1 disp('ERROR176 refer to manual'); return; elseif length(resistance_array) == count3 resistance_array = regexprep(resistance_array, million_set, '.*1000000', 'ignorecase'); resistance_array_call_final = str2num(resistance_array); end_count = end_count + 1; elseif length(resistance_array) ~= count3 temp_array = regexprep(resistance_array, thousand_set, '.', 'ignorecase'); temp2_array = str2num(temp_array); resistance_array_call_final = temp2_array.*1000; end_count = end_count + 1; end end end if resistance_array_call_final == 0; disp('You wont need any resistors for that!'); return else end int_resis_msg = sprintf('Resistance: %10.4f Ohm/s',resistance_array_call_final); disp(int_resis_msg); %-- resistor amount INPUTS/calls -- amount_call = input('What is the maximum amount of resistors allowed?: ', 's'); for count = 1:length(amount_call); x = amount_call(count); if strfind(digits, x) else disp('ERROR:5 (refer to manual)'); return; end end amount_restistors = str2num(amount_call); if amount_restistors >= 10 disp('ERROR:6 (refer to manual)'); return; elseif amount_restistors ~= round(amount_restistors); disp('ERROR:7 (refer to manual)'); return; else end %-- resistance arrays -- resistors = [... 10000000 8200000 6800000 5600000 4700000 3900000 3300000 2700000 ... 2200000 1800000 1500000 1200000 1000000 820000 680000 560000 470000 ... 390000 330000 270000 220000 180000 150000 120000 100000 82000 68000 ... 56000 47000 39000 33000 27000 22000 18000 15000 12000 10000 8200 ... 6800 5600 4700 3900 3300 2700 2200 1800 1500 1200 1000 820 680 560 ... 470 390 330 270 220 180 150 120 100 82 68 56 47 39 33 27 22 18 15 ... 12 10 8.2 6.8 5.6 4.7 3.9 3.3 2.7 2.2 1.8 1.5 1.2 1]; array = rot90(resistors); %-- series -- totalval=resistance_array_call_final; temp=zeros(amount_restistors,1); for n =1:amount_restistors ; for k = 1:length(array); %'k' is created as a new variable so that values can be stored following the length of 'array'. if array(k)-resistance_array_call_final >0 ; %This value of k which was stored is then subtracted from the total resistance value entered by the user and is checked if it is greater than zero. temp(n) = array(k-1); %A temporary variable is then created. This variable is created on the basis of what 'array)k-1) is. This value is copied into a new array. break end end resistance_array_call_final = resistance_array_call_final-temp(n); %The resistor value changes to the new value which needs to be worked out and therefore repeating the loop till all conditions are satisfied if resistance_array_call_final 0; message1=sprintf('Resistor %g is %g Ohm''s',a,temp(a,1)); %This 'sprintf' command is used to display the resistor values used in the calculations. But only the number used, not the maximum amount that could have been used disp(message1); p = p+1; elseif temp(a,1) < 0; message1=sprintf('Resistor %g is %g Ohm''s',a,temp(a,1)); %This 'sprintf' command is used to display the resistor values used in the calculations. But only the number used, not the maximum amount that could have been used disp(message1); p = p+1; elseif temp(a,1) == 0; message2=sprintf('Resistor %g is not required as more accurate value is obtained using %g resistor/s',a,p); disp(message2); end end message4=sprintf('Overall achieved resistance: %10.4f Ohm/s',sum(temp)); disp(message4); if totalval-sum(temp) ~= 0; message2 = sprintf('The error rate is %g percent',abs(totalval-sum(temp))/totalval*100); disp(message2); elseif totalval-sum(temp) == 0; %This whole 'if' loop is used to calculate the percentage error that occurs in the calculations. It displays the error if there one, or displays a 100% match statement if the resistors used are exact. message3 = sprintf('100 percent match, use the above resistors in series'); disp(message3); end Read More
Tags
Cite this document
  • APA
  • MLA
  • CHICAGO
(“Matlab problem Assignment Example | Topics and Well Written Essays - 1250 words”, n.d.)
Matlab problem Assignment Example | Topics and Well Written Essays - 1250 words. Retrieved from https://studentshare.org/logic-programming/1478936-matlab-problem
(Matlab Problem Assignment Example | Topics and Well Written Essays - 1250 Words)
Matlab Problem Assignment Example | Topics and Well Written Essays - 1250 Words. https://studentshare.org/logic-programming/1478936-matlab-problem.
“Matlab Problem Assignment Example | Topics and Well Written Essays - 1250 Words”, n.d. https://studentshare.org/logic-programming/1478936-matlab-problem.
  • Cited: 0 times

CHECK THESE SAMPLES OF Matlab Programming in Solving Problems

Good Financial Engineering Skills

I also have a lot of knowledge about various engineering, applied mathematics, finance, and economics tools that are frequently employed in problem solving techniques used in strategic planning, risk management, and investment.... The subjects of Economics and programming classes of C language and Matlab were also part of my undergraduate course of Electrical Engineering....
1 Pages (250 words) Personal Statement

Comparison of Scripting Languages

The features of Python are the ones that have made it the most convenient programming language over Matlab and Octave.... n addition, Python is a much stronger programming language compared to Matlab and Octave making it the most convenient to use in computing scientific calculations.... These clearly illustrate that Python programming language is stronger compared to Matlab and Octave.... "Comparison of Scripting Languages" paper compares and contrasts matlab, Python, and Octave scripting languages by analyzing....
5 Pages (1250 words) Research Paper

Mathematical Models and Methods

The assignment gave insight into the numerical methods and programming... Temperature distribution along the length of a rod kept at constant temperatures at the ends and insulated elsewhere can be modelled by a a partial differential equation which is first order in time and second order in distance ....
12 Pages (3000 words) Essay

Computing and Programming with MATLAB

in solving for the freefall velocity of the beetle, we shall make use of the MATLAB high-level programming language.... n solving for the freefall velocity of the beetle, we shall make use of the MATLAB high-level programming language, which will assist us to compute and display the results.... The author of the "Computing and programming with MATLAB" paper designs a MATLAB program to calculate the travel time and velocity of two vehicles one moving horizontally while the other moving vertically downwards to cover a distance of one mile (1609m)....
4 Pages (1000 words) Essay

Graph Theory in Computer Science

Now, this theory is being fruitfully used for solving problems related to the manufacture of integrated circuits.... Based on the researches conducted by many computer scientists, they have identified a set of graph problems which has no efficient algorithm for solving those problems.... They are algorithms, cryptography, Fortran, Internet connectivity, logic, Maple programming, Numerical analysis, C, error correction, graph theory, Java, Machine learning, Matlab, and theory of computation....
8 Pages (2000 words) Assignment

Bearing as the Main Part in the Majority of Machines

This aim of this essay is to assist in identifying causes of bearing failures and provide instruction or direction on how to keep away from future problems.... If the machinery is plagued by frequent bearing problems, the explanation that complements the text can provide precious assistance in identifying the root cause of a bearing failure....
16 Pages (4000 words) Coursework

Development of New Mathematical and Engineering Programs

able of Contents Introduction The Mat-Lab program is a very useful tool in solving mathematical problems.... Methods The method used in this study is quantitative analysis using familiar mathematical and engineering problems and applying the variables and equations in the scripts (Campbell, Chancelier and Nikoukhah 2006, p38).... Conclusion In the project, the Mat-Lab and Sci-Lab programs worked successfully and showed that confirmed that indeed, Mathematical computations and Engineering problems can best be solved through programming....
3 Pages (750 words) Lab Report

Mechanical Engineering and MATLAB Environment

ome basic physics background is required before solving the problem.... The paper under the title "Mechanical Engineering and matlab Environment" will be divided into three main steps: understanding the physics behind the problem; planning the program; designing the code that can be executed in a matlab environment....
6 Pages (1500 words) Assignment
sponsored ads
We use cookies to create the best experience for you. Keep on browsing if you are OK with that, or find out how to manage cookies.
Contact Us