Error: File: d3.m Line: 7 Column: 10 Invalid use of operator.

2 次查看(过去 30 天)
datacell = textscan( regexprep( fileread('cricketData.csv'), '\$', '0' ), '%f%f', 'delimiter', ',', 'HeaderLines', 1);
Duration = datacell{1};
Input = datacell{1};
YourTable = table(Duration, Input);
temp=datacell(:,1);
rate=datacell(:,2);
scatter((:,1)),(:,2)),'o')
xlabel('temperature(T in degrees Fahrenheit)')
ylabel('chirping (R in chirp per second))')
title('Chirping rate vs Temperature')
p=polyfit(datacell(:,1),datacell(:,2),1);
x=min((datacell(:,1)))-2:.01:max((datacell(:,2)))+2;
hold on
plot(x,polyval(p,x))
legend('Data points,''best fit equation')
fprintf('Calculated equation: Chirping rate(c/s)=(%.2f)(temperature (F))+%.2f\n',p)

回答(2 个)

Walter Roberson
Walter Roberson 2020-10-7
scatter((:,1)),(:,2)),'o')
The : operator needs to have a variable or constant on each side if it when it is being used as the range-construction operator.
When : is used as a subscript by itself, then it needs to appear inside an indexing expression. For example,
scatter(rate(:,1),(2:5)),'o')
| |
| +--- range operator
|
+---- subscript operator

James Tursa
James Tursa 2020-10-7
Looks like you are missing some variable names and some matching parentheses in this line:
scatter((:,1)),(:,2)),'o')

类别

Help CenterFile Exchange 中查找有关 Numeric Types 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by