error using linspace: input must be scalars
44 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Heera
am 8 Dez. 2020
Beantwortet: SALINI BALASUBARAMANIUM
am 28 Mär. 2022
clear all;
table = readtable ('data_part1.xlsx', 'Range', 'A1:E13')
sigma = table. (3) (1:12);
energy = table. (4) (1:12);
C12 = 4 * energy .* sigma.^12;
C6 = 4 * energy .* sigma.^6;
r = linspace (sigma * 0.95, sigma * 2.5, 12)
data has been imported from an excel spreadsheet hence the references, unsure of how to get rid of this error message on the last line of code? (0.95 and 2.5 are my min and max respectively)
0 Kommentare
Akzeptierte Antwort
Cris LaPierre
am 8 Dez. 2020
You define sigma as a vector (12 numbers). In linspace, your input is sigma multiplied by 0.95 or 2.5. This only scales the values in your vector. The inputs are still vectors. However, they must be scalars (one number).
% Valid syntax
linspace(0,5,10)
% Incorrect syntax
linspace([0:5],[20:25],12)
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu Spreadsheets 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!