Help Print Command Error
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
function [dy] = y(n,to,t,y0)
t=[0:0.01:5] h=[0.1 0.001] t0=0 y0=1 n=50 h=0.1 t=t0 y=y0
Hello, i'm new to matlab and have developed the following code for a euler solver. for i=1:n k=2-exp(-4*t)-2*y y=y+h*k t=t+h
print('t','y')
end
I'm trying to use the print command but am getting the following error.
Error using inputcheck (line 40) Multiple inputs that look like filenames: 't' and 'y'
Error in print (line 163) [pj, devices, options ] = inputcheck( pj, inputargs{:} );
Error in bmes511_hw3 (line 18) print('t','y')
Any ideas why?
3 Kommentare
Mischa Kim
am 7 Feb. 2014
Do you simply want to display the variables in the command window? The print command is used to print a figure.
Antworten (1)
Mischa Kim
am 7 Feb. 2014
Bearbeitet: Mischa Kim
am 7 Feb. 2014
OK. Use
sprintf('%5.2f: %5.2f', t, y)
or something like that. With the %5.2f you can specify the number format: total of five digits, two after the decimal point, fixed-point. Check out the documentation for a full description of the formatting syntax.
1 Kommentar
Mischa Kim
am 7 Feb. 2014
Careful, I just looked at your code. You first define t as a vector, then you re-assign it into a scalar by t = t0.
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!