Question

In: Electrical Engineering

q1) using Matlab make a code that allows a user to enter a function like fractional...

q1) using Matlab

make a code that allows a user to enter a function like fractional function and cubic liner function then the Matlab send a domain, range, continuity

Solutions

Expert Solution

Good, definitely, this concern may also be clear up really trivially in a technique that does not require lsqlin, or anything fancy. There relatively is not any requirement for a linear constraint, for the reason that the constraint will probably be that the consistent parameter within the polynomial model is solely zero. So use backslash to estimate the mannequin coefficients, and simply go away out the constant term. Word that this works most effective to drive a factor by means of the starting place, due to the fact the factor (x,y) = (zero,zero) in a polynomial model implies that the constant term ought to be identically zero.

So, given a mannequin of the form

y = a1*x^three + a*x^2 + a3*x
we are able to fit it with ease as

a123 = [x.^3, x.^2, x]y;
where x and y are column vectors of data.

Which you could even use polyval to assess the polynomial, quite simply by means of appending a zero to the top of that vector f coefficients, for that reason

P = [a123;0];
in case you desired to force the mode to go by way of the factor (x0,y0), the place these values aren't the starting place, then we have to work slightly extra, however no longer a lot. While you can do so with lsqlin, should you would not have that tool (or my own LSE, as observed on the file exchange) simply do this easy transformation:

xtr = x - x0;
a123 = [xtr.^3, xtr.^2, xtr](y - y0);
essentially, we've got now fit the model

y - y0 = a1*(x - x0)^3 + a*(x - x0)^2 + a3*(x - x0)
you will find that after x == x0, y ought to be estimated as y0.

Analysis of this model is solely as convenient. That you could still use polyval, simply bear in mind to subtract off x0 from x first.

P = [a123;y0];
ypred = polyval(P,xpred - x0);
What occurs when we now have a more problematic concern, the place might be you need to drive TWO aspects on the curve? Good, then, you should utilize either lsqlin or my possess LSE. (observe that LSE runs in R2015a with out a warning messages.)

Or, you probably have a trigonometric mannequin? If the model has nonlinear parameters in it, then you're going to have to use a nonlinear optimization. And relying on the mannequin, to force it by way of a given factor, that will require a nonlinear tool that may manage an equality constraint, so possibly fmincon. However usually, once more, relying on the mannequin, there could also be less difficult solutions. All of it depends upon the model.


Related Solutions

q1) using Matlab make a code that allows a user to enter a function like fractional...
q1) using Matlab make a code that allows a user to enter a function like fractional function and cubic liner function then the Matlab send a domain, range, continuity
Make a function in C that allows for the user to enter in 2 separate strings....
Make a function in C that allows for the user to enter in 2 separate strings. The first string that is entered is then made equal to the second string, but any duplicate characters (the same character appearing twice or more in a row) should only be copied once to the output string. Lastly the function displays how many duplicate characters were found.
Using PHP, Make a form that allows the user to enter the weight of the item...
Using PHP, Make a form that allows the user to enter the weight of the item being shipped. This will be used to calculate the shipping cost.Create a form that uses the method POST The form should capture a customer's package weight with the one field for the package weight in pounds. All fields should have the REQUIRED attribute. The form should have a submit button and a reset button. The form should look nice. All the labels should line...
Write out code for a nested if statement that allows a user to enter in a...
Write out code for a nested if statement that allows a user to enter in a product name, store the product into a variable called product name and checks to see if that product exists in your nested if statement. You must include 5 product names to search for. If it is then assign the price of the item to a variable called amount and then print the product name and the cost of the product to the console. If...
Write a MATLAB program to do the following: 1- Allows the user to enter unlimited number...
Write a MATLAB program to do the following: 1- Allows the user to enter unlimited number of data set. 2- Allows the user to exit the program at any time by entering zero. 3- Calculates and displays the following statistics for the entered data set: a- Count of positive, negative, and total numbers. b- Maximum and Minimum numbers. c- Sum and Average of positive numbers. d- Sum and Average of negative numbers. e- Overall Sum and overall average of all...
Write Java code that allows a user to repeatedly enter numbers. Each time the user enters...
Write Java code that allows a user to repeatedly enter numbers. Each time the user enters a number, the program should print out the average of the last 3 numbers (or all numbers if 3 or less have been entered). I would like a detailed explanation so that a beginner level Java programmer could understand.
Please write the code JAVA Write a program that allows the user to enter the last...
Please write the code JAVA Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate. The program should then output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. A sample output is: Candidate      Votes Received                                % of Total Votes...
C++ Write the C++ code for a void function that prompts the user to enter a...
C++ Write the C++ code for a void function that prompts the user to enter a name, and then stores the user's response in the string variable whose address is passed to the function. Name the function getName.
Using python, allows a user to enter the values of two, 3x3 matrices and then select...
Using python, allows a user to enter the values of two, 3x3 matrices and then select from options including, addition, subtraction, matrix multiplication, and element by element multiplication. You should use numpy.matmul()for matrix multiplication(e.g. np.matmul(a, b)).The program should computer the appropriate results and return the results, the transpose of the results, the mean of the rows for the results, and the mean of the columns for the results.When entering data you should check that each value is numeric for the...
DATA STRUCTURES USING C++ 2ND EDITION Write a program that allows the user to enter the...
DATA STRUCTURES USING C++ 2ND EDITION Write a program that allows the user to enter the last names of five candidates in a local election and the votes received by that candidate. The program should then output each candidates name, votes received by that candidate, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. A sample output is as follow Johnson    5000 25.91 miller    4000   ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT