Introductory Circuit Analysis (13th Edition)
Introductory Circuit Analysis (13th Edition)
13th Edition
ISBN: 9780133923605
Author: Robert L. Boylestad
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

That is a Matlab problem

Write a function to return the index of the value that is nearest to a desired value. The
function declaration should be: ind = FindNearest(x, desiredVal). x can be a vector or
matrix, and desiredVal is the scalar value you want to find. Do not assume that
desiredVal exists in x, rather find the value that is closest to desiredVal. If multiple
values are the same distance from desiredVal, return all of their indices. Test your
function to make sure it works on a few vectors and matrices. Useful functions are abs,
min, and find. Hint: You may have some trouble using min when x is a matrix. To
convert a matrix A into a vector you can use the expression b = A(:). Then, expression
minVal = min(b) will give you the minimum value in A. To find where this minimum
occurs in A, do inds = find(A == minVal);.
expand button
Transcribed Image Text:Write a function to return the index of the value that is nearest to a desired value. The function declaration should be: ind = FindNearest(x, desiredVal). x can be a vector or matrix, and desiredVal is the scalar value you want to find. Do not assume that desiredVal exists in x, rather find the value that is closest to desiredVal. If multiple values are the same distance from desiredVal, return all of their indices. Test your function to make sure it works on a few vectors and matrices. Useful functions are abs, min, and find. Hint: You may have some trouble using min when x is a matrix. To convert a matrix A into a vector you can use the expression b = A(:). Then, expression minVal = min(b) will give you the minimum value in A. To find where this minimum occurs in A, do inds = find(A == minVal);.
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Electrical Engineering
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, electrical-engineering and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Introductory Circuit Analysis (13th Edition)
Electrical Engineering
ISBN:9780133923605
Author:Robert L. Boylestad
Publisher:PEARSON
Text book image
Delmar's Standard Textbook Of Electricity
Electrical Engineering
ISBN:9781337900348
Author:Stephen L. Herman
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Electrical Engineering
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Text book image
Fundamentals of Electric Circuits
Electrical Engineering
ISBN:9780078028229
Author:Charles K Alexander, Matthew Sadiku
Publisher:McGraw-Hill Education
Text book image
Electric Circuits. (11th Edition)
Electrical Engineering
ISBN:9780134746968
Author:James W. Nilsson, Susan Riedel
Publisher:PEARSON
Text book image
Engineering Electromagnetics
Electrical Engineering
ISBN:9780078028151
Author:Hayt, William H. (william Hart), Jr, BUCK, John A.
Publisher:Mcgraw-hill Education,