A problem with inputting a function from the user
Mostra commenti meno recenti
I used the input function to input a handel-function from the user
The command window keeps asking me to input the fuction again in each time i mentiond the function in the scribt.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
%% The General Least Square Regression'
clear all,close all; clc
syms t
disp('The General Least Square Regression ')
ti = input ('Inter the values of t [t0,t1,...] : ');
y = input ('Inter the values of y [y0,y1,...] : ')';
disp('Note: If your function is a constant please inter the (constant)*(t.^0)')
Z0 =@(t) input ('Inter the first bais z0 in terms of t : ');
Z1 =@(t) input ('Inter the second bais z1 in terms of t : ');
Z2 =@(t) input ('Inter the third bais z2 in terms of t : ');
z0=Z0(ti)';
z1=Z1(ti)';
z2=Z2(ti)';
Z=[z0 z1 z2];
Zs=Z'*Z;
ys=Z'*y;
yr=(Zs^-1)*ys;
tplot=[0:0.01:8];
zp0=Z0(tplot);
zp1=Z1(tplot);
zp2=Z2(tplot);
THE COMMAND WINDOW
The General Least Square Regression
Inter the values of t [t0,t1,...] : [1:8]
Inter the values of y [y0,y1,...] : [22 12 9 13 11 11 12 10]
Note: If your function is a constant please inter the (constant)*(t.^0)
Inter the first bais z0 in terms of t : t.^0
Inter the second bais z1 in terms of t : exp(-t).*cos(10*t)
Inter the third bais z2 in terms of t : (t.^-1).*sin(10*t)
yr =
11.3280
-46.1728
6.6732
Inter the first bais z0 in terms of t : t.^0
Inter the second bais z1 in terms of t : exp(-t).*cos(10*t)
Inter the third bais z2 in terms of t : (t.^-1).*sin(10*t)
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Creating, Deleting, and Querying Graphics Objects in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!