필터 지우기
필터 지우기

error using linspace: input must be scalars

조회 수: 44 (최근 30일)
Heera
Heera 2020년 12월 8일
답변: SALINI BALASUBARAMANIUM 2022년 3월 28일
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)

채택된 답변

Cris LaPierre
Cris LaPierre 2020년 12월 8일
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)
ans = 1×10
0 0.5556 1.1111 1.6667 2.2222 2.7778 3.3333 3.8889 4.4444 5.0000
% Incorrect syntax
linspace([0:5],[20:25],12)
Error using linspace (line 22)
Inputs must be scalars.

추가 답변 (1개)

SALINI  BALASUBARAMANIUM
SALINI BALASUBARAMANIUM 2022년 3월 28일
ObsrvWindow = linspace(1,100,K);

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by