Azzera filtri
Azzera filtri

How can I get data from evaluating a function, say y=x^2+5 and put it in table?

1 visualizzazione (ultimi 30 giorni)
How can I get data from evaluating a function, say y=x^2+5 for x=0.1 to 0.9 for 50 points in between and put it in table?

Risposta accettata

the cyclist
the cyclist il 23 Set 2021
x = linspace(0.1,0.9,50);
y = x.^2+5;
tbl = table(y.');
  3 Commenti
the cyclist
the cyclist il 23 Set 2021
The semicolon at the end of a line of MATLAB code suppresses the output. So just leave the semicolon off of any line you want displayed to the command window.
x = linspace(0.1,0.9,50)
x = 1×50
0.1000 0.1163 0.1327 0.1490 0.1653 0.1816 0.1980 0.2143 0.2306 0.2469 0.2633 0.2796 0.2959 0.3122 0.3286 0.3449 0.3612 0.3776 0.3939 0.4102 0.4265 0.4429 0.4592 0.4755 0.4918 0.5082 0.5245 0.5408 0.5571 0.5735
y = x.^2+5
y = 1×50
5.0100 5.0135 5.0176 5.0222 5.0273 5.0330 5.0392 5.0459 5.0532 5.0610 5.0693 5.0782 5.0876 5.0975 5.1080 5.1190 5.1305 5.1425 5.1551 5.1683 5.1819 5.1961 5.2108 5.2261 5.2419 5.2582 5.2751 5.2925 5.3104 5.3289
tbl = table(y.')
tbl = 50×1 table
Var1 ______ 5.01 5.0135 5.0176 5.0222 5.0273 5.033 5.0392 5.0459 5.0532 5.061 5.0693 5.0782 5.0876 5.0975 5.108 5.119
These are very basic MATLAB questions. You might want to watch the MATLAB Onramp tutorial.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by