Summation using a for loop and putting data into a matrix

1 vue (au cours des 30 derniers jours)
christian basa
christian basa le 29 Jan 2020
Commenté : Mohammad Sami le 29 Jan 2020
  1. Consider the model y(t)=tan(u*0.9*pi/2) evaluated for the inputs u= linspace(0,1,N). Use the model structure: 1
y_hat = sum from i = 0 to n of theta*u^i
to describe these data. Note that this is a nonlinear model that is linear-in-the- parameters ?.
  • Generate a dataset of y based on the model. N = 100.
  • Create a Matlab script that solves for varying orders of the model structure (n varies from 1 to 20). Make sure to save the different parameters (n = 1 will have 2 parameters in theta, n = 2 will have 3, and so on).
  • Plot the estimated output ?- for n = 1, 5, 10 and 15 as well as the true output (from the model) on a single plot.
I hope this makes sense
I am able to create the summation using a for loop, but I don't know how to put it into a matrix. My professor said something about concatinating the data so that we end up with a 100x21 matrix, with all 1's being in the first column and the calculate "u" value is going across.
  2 commentaires
Allen
Allen le 29 Jan 2020
Here a link to the MATLAB's reference page for array (aka. matrix) indexing. It explains the general concept of how to access single elements, rows, or columns of an array.
Another resource for creating and concatenating arrays.
Mohammad Sami
Mohammad Sami le 29 Jan 2020
A good starting point to learn Matlab is to complete Matlab Onramp course.
https://www.mathworks.com/learn/tutorials/matlab-onramp.html

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by