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

2 vues (au cours des 30 derniers jours)
Hansu Kim
Hansu Kim le 7 Oct 2020
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)

Réponses (2)

Walter Roberson
Walter Roberson le 7 Oct 2020
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 le 7 Oct 2020
Looks like you are missing some variable names and some matching parentheses in this line:
scatter((:,1)),(:,2)),'o')

Catégories

En savoir plus sur Numeric Types dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by