Question

what did i do wrong in here? error said I have wrong code for scatter(rate(:,1),rate(:,5),'o') but...

what did i do wrong in here? error said I have wrong code for scatter(rate(:,1),rate(:,5),'o') but when I solved it, other codes are messed up how to solve it?

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(rate(:,1),rate(:,5),'o')
xlabel('temperature(T in degrees Fahrenheit)')
ylabel('chirping (R in chirp per second))')
title('Chirping rate vs Temperature')
p=polyfit(rate(:,1),rate(:,2),1);
x=min(1)-2:.01:max(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)

Homework Answers

Answer #1

Answer:

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(rate(:,1),(2:5)),'o')
xlabel('temperature(T in degrees Fahrenheit)')
ylabel('chirping (R in chirp per second))')
title('Chirping rate vs Temperature')
p=polyfit(rate(:,1),rate(:,2),1);
x=min(1)-2:.01:max(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)

Explanation:

  • You have put
    • scatter(rate(:,1),rate(:,5),'o')
  • But we have to put this as
    • When : is used as a subscript by itself, then it needs to appear inside an indexing expression.
    • scatter(rate(:,1),(2:5)),'o')
    • | |
    • | +--- range operator
    • |
    • +---- subscript operator
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions