Undefined operator '*' for input arguments of type 'categorical'.

1 view (last 30 days)
I couldn't able to clear the mentioned error. The following is the whole code:
load sample
DeviceTime=sample{:,2};
acc=sample{:,15};
throttle=sample{:,14};
fuel_rate=sample{:,39};
plot(DeviceTime,throttle);
hold on;
top=0.1;
[pks,locs]=findpeaks(throttle,"MinPeakHeight",top);
plot(DeviceTime(locs),pks,"ro")
xlabel("time");
ylabel("throttle position");
title("Time vs Throttle");% I can able to plot upto here. Here onwards I am getting error.
avg_pks=mean(pks);
%% I tried in this way also.
% A=3.7854;
% B=categorical(A,160);
% load Gallon_Litres
% fuel_rate_Pm=(B*fuel_rate)/60;
% disp('fuel_rate_Pm')
fuel_rate=(3.7854*fuel_rate)/60; % Erroe line %%It is actually a conversion of fuel rate from gallon to litres
trip_avg_val=sample{:,70};
trip_avg=sum(trip_avg_val,'all')/length(trip_avg_val);
[fuel_consumed,fuel_cost,avg_speed,dist_travelled]=fuel_cap(fuel_rate,trip_avg);
plot(avg_speed);hold on;
xlabel('time');
ylabel('KmpH');
title('AVERAGE SPEED PLOT');
plot(mean_spd,"ro");hold off;

Accepted Answer

Star Strider
Star Strider on 16 May 2021
I am not certain what the problem is, and some information is not available.
Try something like this —
sample = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/619573/sample.xlsx', 'VariableNamingRule','preserve')
sample = 160×81 table
GPS Time Device Time Longitude Latitude GPS Speed (Meters/second) Horizontal Dilution of Precision Altitude Bearing G(x) G(y) G(z) G(calibrated) 0-100kph Time(s) Absolute Throttle Position B(%) Acceleration Sensor(Total)(g) Acceleration Sensor(X axis)(g) Acceleration Sensor(Y axis)(g) Acceleration Sensor(Z axis)(g) Accelerator PedalPosition D(%) Accelerator PedalPosition E(%) Accelerator PedalPosition F(%) Actual engine % torque(%) Air Fuel Ratio(Commanded)(:1) Ambient air temp(°C) Average trip speed(whilst moving only)(km/h) Average trip speed(whilst stopped or moving)(km/h) Barometric pressure (from vehicle)(psi) CO₂ in g/km (Average)(g/km) DPF Pressure(psi) DPF Temperature(°C) Engine Coolant Temperature(°C) Engine kW (At the wheels)(kW) Engine Load(%) Engine Load(Absolute)(%) Engine Oil Temperature(°C) Engine reference torque(Nm) Engine RPM(rpm) Fuel cost (trip)(cost) Fuel flow rate/hour(gal/hr) Fuel flow rate/minute(gal/min) Fuel Remaining (Calculated from vehicle profile)(%) Fuel Trim Bank 1 Long Term(%) Fuel trim bank 1 sensor 1(%) Fuel trim bank 1 sensor 2(%) Fuel Trim Bank 1 Short Term(%) GPS Accuracy(m) GPS Altitude(m) GPS Bearing(°) GPS Latitude(°) GPS Longitude(°) GPS Satellites GPS vs OBD Speed difference(km/h) Horsepower (At the wheels)(hp) Intake Air Temperature(°C) Intake Manifold Pressure(psi) Kilometers Per Litre(Instant)(kpl) Kilometers Per Litre(Long Term Average)(kpl) Litres Per 100 Kilometer(Long Term Average)(l/100km) Miles Per Gallon(Instant)(mpg) Miles Per Gallon(Long Term Average)(mpg) O2 Volts Bank 1 sensor 1(V) O2 Volts Bank 1 sensor 2(V) Relative Throttle Position(%) Run time since engine start(s) Speed (GPS)(km/h) Speed (OBD)(km/h) Throttle Position(Manifold)(%) Timing Advance(°) Torque(Nm) Trip average KPL(kpl) Trip average Litres/100 KM(l/100km) Trip average MPG(mpg) Trip Distance(km) Trip Time(Since journey start)(s) Trip time(whilst moving)(s) Trip time(whilst stationary)(s) Turbo Boost & Vacuum Gauge(psi) Turbo Pressure Control(psi) Voltage (Control Module)(V) Voltage (OBD Adapter)(V) Volumetric Efficiency (Calculated)(%) ______________________________________ ____________________ _________ ________ _________________________ ________________________________ ________ _______ _________ ______ ______ _____________ ________________ _______________________________ _____________________________ ______________________________ ______________________________ ______________________________ ______________________________ ______________________________ ______________________________ _________________________ _____________________________ _____________________ ____________________________________________ __________________________________________________ _______________________________________ _____________________________ _________________ ____________________ _______________________________ _____________________________ ______________ ________________________ ___________________________ ___________________________ _______________ ______________________ ___________________________ ______________________________ ___________________________________________________ _____________________________ ____________________________ ____________________________ ______________________________ _______________ _______________ _______________ ________________ _________________ ______________ _________________________________ ______________________________ ___________________________ _____________________________ __________________________________ ____________________________________________ ____________________________________________________ ______________________________ ________________________________________ ___________________________ ___________________________ _____________________________ ______________________________ _________________ _________________ ______________________________ __________________ __________ _____________________ ___________________________________ _____________________ _________________ _________________________________ ___________________________ _______________________________ _______________________________ ___________________________ ___________________________ ________________________ _____________________________________ {'Sun Nov 03 14:12:50 GMT+05:30 2019'} 03-Nov-2019 14:12:53 78.537 17.341 0.44 3.216 424.28 199 -0.91495 7.8303 5.001 -0.0026965 {'-'} NaN -0.027866 -0.061889 0.76841 0.49171 NaN NaN {'-'} {'-'} {'-'} {'-'} NaN NaN NaN {'-'} {'-'} {'-'} 57 {'-'} NaN NaN {'-'} {'-'} NaN NaN NaN NaN NaN NaN NaN {'-'} NaN 3.216 NaN 199 NaN NaN NaN NaN {'-'} NaN 7.3969 NaN 14.523 6.8857 NaN 34.16 NaN NaN NaN NaN NaN NaN NaN NaN {'-'} NaN NaN NaN NaN 0 0 0 -7.3031 {'-'} NaN NaN {'-'} {'Sun Nov 03 14:12:50 GMT+05:30 2019'} 03-Nov-2019 14:12:54 78.537 17.341 0.44 3.216 424.28 199 -0.36998 8.2268 4.9363 -0.026558 {'-'} NaN -0.042558 -0.097785 0.77109 0.4585 NaN NaN {'-'} {'-'} {'-'} {'-'} 11 11 NaN {'-'} {'-'} {'-'} 58 {'-'} 42.353 NaN {'-'} {'-'} 2376.5 NaN NaN NaN NaN NaN NaN {'-'} NaN 3.216 NaN 199 NaN NaN NaN 11 {'-'} 33 7.3969 NaN 14.523 6.8857 NaN 34.16 NaN NaN NaN NaN NaN 11 NaN NaN {'-'} NaN NaN NaN NaN 0 0.634 0 -7.3031 {'-'} NaN NaN {'-'} {'Sun Nov 03 14:12:50 GMT+05:30 2019'} 03-Nov-2019 14:12:55 78.537 17.341 0.44 3.216 424.28 199 -1.1809 6.4529 8.0396 0.034718 {'-'} NaN 0.047209 -0.10365 0.64693 0.71648 NaN NaN {'-'} {'-'} {'-'} {'-'} 11 11 NaN {'-'} {'-'} {'-'} 58 {'-'} 42.353 NaN {'-'} {'-'} 2376.5 NaN NaN NaN NaN NaN 0.78125 {'-'} 2.3438 3.216 NaN 199 NaN NaN NaN 11 {'-'} 33 7.3969 NaN 14.523 6.8857 NaN 34.16 0.84 0.845 NaN NaN NaN 11 18.039 20 {'-'} NaN NaN NaN NaN 1 1.493 0 -7.3031 {'-'} 14.229 NaN {'-'} {'Sun Nov 03 14:12:56 GMT+05:30 2019'} 03-Nov-2019 14:12:56 78.537 17.341 2.37 7.504 421.94 177.4 0.73673 7.0578 6.2466 0.053365 {'-'} NaN -0.0030282 -0.059203 0.69137 0.61539 NaN NaN {'-'} {'-'} {'-'} {'-'} 11 11 13.779 {'-'} {'-'} {'-'} 58 {'-'} 42.353 NaN {'-'} {'-'} 2376.5 NaN NaN NaN NaN -2.3438 0.78125 {'-'} 2.3438 7.504 421.94 177.4 17.341 78.537 8 11 {'-'} 33 7.3969 NaN 14.523 6.8857 NaN 34.16 0.84 0.845 NaN NaN NaN 11 18.039 20 {'-'} NaN NaN NaN NaN 2 2.03 0 -7.3031 {'-'} 14.229 13.5 {'-'} {'Sun Nov 03 14:12:57 GMT+05:30 2019'} 03-Nov-2019 14:12:57 78.537 17.341 2.38 8.576 422.05 181.3 0.1678 8.1861 5.4441 -0.015128 {'-'} 21.176 -0.04121 0.0751 0.80113 0.42077 30.196 15.294 {'-'} {'-'} {'-'} {'-'} 11 11 13.779 {'-'} {'-'} {'-'} 58 {'-'} 42.353 NaN {'-'} {'-'} 2376.5 NaN NaN NaN NaN -2.3438 0.78125 {'-'} 2.3438 8.576 422.05 181.3 17.341 78.537 8 11 {'-'} 33 7.3969 NaN 14.523 6.8857 NaN 34.16 0.84 0.845 4.3137 NaN 8.568 11 18.039 20 {'-'} NaN NaN NaN NaN 3 3.551 0 -7.3031 {'-'} 14.229 13.5 {'-'} {'Sun Nov 03 14:12:58 GMT+05:30 2019'} 03-Nov-2019 14:12:58 78.537 17.341 2.37 6.432 422.78 170.5 -0.28614 5.8361 7.0635 -0.017188 {'-'} 21.176 -0.011367 -0.0038948 0.78929 0.49476 30.196 15.294 {'-'} {'-'} {'-'} {'-'} 11 11 13.779 {'-'} {'-'} {'-'} 58 {'-'} 42.353 29.412 {'-'} {'-'} 2376.5 NaN NaN NaN NaN -2.3438 0.78125 {'-'} 2.3438 6.432 422.78 170.5 17.341 78.537 10 11 {'-'} 33 7.3969 NaN 14.523 6.8857 NaN 34.16 0.84 0.845 4.3137 197 8.532 11 18.039 20 {'-'} NaN NaN NaN NaN 4 4.238 0 -7.3031 {'-'} 14.229 13.5 {'-'} {'Sun Nov 03 14:12:59 GMT+05:30 2019'} 03-Nov-2019 14:12:59 78.537 17.341 2.69 6.432 424.24 164.6 -0.16158 7.6758 7.5821 -0.0073006 {'-'} 21.176 -0.12198 0.080716 0.64436 0.49049 30.196 15.294 {'-'} {'-'} {'-'} {'-'} 11 11 13.779 {'-'} {'-'} {'-'} 58 {'-'} 42.353 29.412 {'-'} {'-'} 2376.5 NaN NaN NaN NaN -2.3438 0.78125 {'-'} 2.3438 6.432 424.24 164.6 17.341 78.537 16 11 {'-'} 33 7.3969 NaN 14.523 6.8857 NaN 34.16 0.84 0.845 4.3137 197 9.684 11 18.039 20 {'-'} NaN NaN NaN NaN 4 4.965 0 -7.3031 {'-'} 14.229 13.5 {'-'} {'Sun Nov 03 14:13:00 GMT+05:30 2019'} 03-Nov-2019 14:13:00 78.537 17.341 2.26 4.288 425.17 166.1 0.18577 7.386 7.2623 0.014876 {'-'} 21.176 -0.066844 0.070094 0.66463 0.5508 30.196 15.294 {'-'} {'-'} {'-'} {'-'} 11 11 13.779 {'-'} {'-'} {'-'} 59 {'-'} 42.353 29.412 {'-'} {'-'} 2376.5 NaN NaN NaN NaN -2.3438 0.78125 {'-'} 2.3438 4.288 425.17 166.1 17.341 78.537 21 11 {'-'} 33 3.4809 181.25 12.093 8.2692 512 34.16 0.84 0.845 4.3137 197 8.136 11 18.039 20 {'-'} 13.302 7.5176 37.576 NaN 6 6.597 0 -10.298 {'-'} 14.229 13.5 {'-'} {'Sun Nov 03 14:13:01 GMT+05:30 2019'} 03-Nov-2019 14:13:01 78.537 17.341 1.67 4.288 426.51 176.6 0.38699 7.083 6.2382 0.00016348 {'-'} 21.176 0.023038 0.0025762 0.76755 0.57583 30.196 15.294 {'-'} {'-'} {'-'} {'-'} 7 7 13.779 {'-'} {'-'} {'-'} 59 {'-'} 19.608 29.412 {'-'} {'-'} 862.5 NaN NaN NaN NaN -2.3438 0.78125 {'-'} 2.3438 4.288 426.51 176.6 17.341 78.537 22 3.012 {'-'} 33 3.4809 181.25 12.093 8.2692 512 34.16 0.84 0.845 4.3137 197 6.012 3 18.039 20 {'-'} 13.302 7.5176 37.576 NaN 7 7.423 0 -10.298 {'-'} 14.229 13.5 {'-'} {'Sun Nov 03 14:13:02 GMT+05:30 2019'} 03-Nov-2019 14:13:02 78.537 17.341 0.71 3.216 425.9 196.9 -3.314 5.8445 8.6828 0.13813 {'-'} 21.176 -0.024739 0.0856 0.68441 0.58902 30.196 15.294 {'-'} {'-'} {'-'} {'-'} 7 7 13.779 {'-'} {'-'} {'-'} 59 {'-'} 19.608 29.412 {'-'} {'-'} 862.5 NaN NaN NaN NaN -2.3438 -5.4688 {'-'} -4.6875 3.216 425.9 196.9 17.341 78.537 23 3.012 {'-'} 33 3.4809 181.25 12.093 8.2692 512 34.16 0.915 0.885 4.3137 197 2.556 3 12.549 17 {'-'} 13.302 7.5176 37.576 NaN 8 8.728 0 -10.298 {'-'} 14.112 13.5 {'-'} {'Sun Nov 03 14:13:03 GMT+05:30 2019'} 03-Nov-2019 14:13:03 78.537 17.341 0.47 3.216 426.44 219.6 -0.15319 7.2446 6.4838 0.0056805 {'-'} 21.176 -0.009756 -0.015982 0.74839 0.54775 30.196 15.294 {'-'} {'-'} {'-'} {'-'} 7 7 13.779 {'-'} {'-'} {'-'} 59 {'-'} 19.608 29.412 {'-'} {'-'} 862.5 NaN NaN NaN NaN -3.9062 -5.4688 {'-'} -4.6875 3.216 426.44 219.6 17.341 78.537 24 3.012 {'-'} 33 3.4809 181.25 12.093 8.2692 512 34.16 0.915 0.885 4.3137 197 1.692 3 12.549 17 {'-'} 13.302 7.5176 37.576 NaN 9 9.268 0 -10.298 {'-'} 14.112 13.5 {'-'} {'Sun Nov 03 14:13:04 GMT+05:30 2019'} 03-Nov-2019 14:13:04 78.537 17.341 0 3.216 427.08 0 0.067193 7.2231 6.2466 0.0065358 {'-'} 21.176 -0.0083169 -0.0024297 0.72787 0.57302 30.196 15.294 {'-'} {'-'} {'-'} {'-'} 7 7 13.779 {'-'} {'-'} {'-'} 59 {'-'} 19.608 29.412 {'-'} {'-'} 862.5 NaN NaN NaN NaN -3.9062 -5.4688 {'-'} -4.6875 3.216 427.08 0 17.341 78.537 24 3.012 {'-'} 33 3.4809 181.25 12.093 8.2692 512 34.16 0.915 0.885 7.0588 197 0 3 12.549 17 {'-'} 13.302 7.5176 37.576 NaN 10 10.789 0 -10.298 {'-'} 14.112 14.3 {'-'} {'Sun Nov 03 14:13:05 GMT+05:30 2019'} 03-Nov-2019 14:13:05 78.537 17.341 0.28 3.216 426.74 219.8 0.46724 7.2973 5.8034 -0.02938 {'-'} 17.255 -0.044562 0.051536 0.75644 0.48084 25.882 12.941 {'-'} {'-'} {'-'} {'-'} 7 7 13.779 {'-'} {'-'} {'-'} 59 {'-'} 19.608 27.451 {'-'} {'-'} 862.5 NaN NaN NaN NaN -3.9062 -5.4688 {'-'} -4.6875 3.216 426.74 219.8 17.341 78.537 24 3.012 {'-'} 33 3.4809 181.25 12.093 8.2692 512 34.16 0.915 0.885 7.0588 197 1.008 3 12.549 17 {'-'} 13.302 7.5176 37.576 NaN 11 11.706 0 -10.298 {'-'} 14.112 14.3 {'-'} {'Sun Nov 03 14:13:06 GMT+05:30 2019'} 03-Nov-2019 14:13:06 78.537 17.341 0.91 3.216 425.95 218 0.056413 6.4314 6.3053 0.036332 {'-'} 17.255 -0.13947 0.34432 0.60016 0.41113 25.882 12.941 {'-'} {'-'} {'-'} {'-'} 7 7 13.779 {'-'} {'-'} {'-'} 59 {'-'} 19.608 27.451 {'-'} {'-'} 862.5 NaN NaN NaN NaN -3.9062 -5.4688 {'-'} -4.6875 3.216 425.95 218 17.341 78.537 22 3.012 {'-'} 33 3.4809 181.25 12.093 8.2692 512 34.16 0.915 0.885 7.0588 204 3.276 3 12.549 17 {'-'} 13.302 7.5176 37.576 NaN 11 11.966 0 -10.298 {'-'} 14.112 14.3 {'-'} {'Sun Nov 03 14:13:07 GMT+05:30 2019'} 03-Nov-2019 14:13:07 78.537 17.341 1.9 3.216 425.67 201.2 -0.057372 7.483 5.8046 0.040438 {'-'} 17.255 0.059432 -0.11549 0.73032 0.65824 25.882 12.941 {'-'} {'-'} {'-'} {'-'} 7 7 13.779 {'-'} {'-'} {'-'} 59 {'-'} 19.608 27.451 {'-'} {'-'} 862.5 NaN NaN NaN NaN -3.9062 -5.4688 {'-'} -4.6875 3.216 425.67 201.2 17.341 78.537 23 3.012 {'-'} 33 3.4809 181.25 12.093 8.2692 512 34.16 0.915 0.885 7.0588 204 6.84 3 12.549 17 {'-'} 13.302 7.5176 37.576 NaN 12 12.967 0 -10.298 {'-'} 14.112 14.3 {'-'} {'Sun Nov 03 14:13:08 GMT+05:30 2019'} 03-Nov-2019 14:13:08 78.537 17.341 2.45 3.216 425.61 198.4 0.89603 6.441 9.7069 0.045983 {'-'} 17.255 0.082928 0.0070936 0.64949 0.76605 25.882 12.941 {'-'} {'-'} {'-'} {'-'} 7 7 13.779 {'-'} {'-'} {'-'} 60 {'-'} 19.608 27.451 {'-'} {'-'} 1168.5 NaN NaN NaN NaN -3.9062 -5.4688 {'-'} -4.6875 3.216 425.61 198.4 17.341 78.537 22 3.012 {'-'} 33 7.687 181.25 12.093 8.269 512 34.161 0.915 0.885 7.0588 204 8.82 3 12.549 17 {'-'} 13.302 7.5175 37.576 NaN 14 14.708 0 -6.0916 {'-'} 14.112 14.3 {'-'}
VN = sample.Properties.VariableNames
VN = 1×81 cell array
{'GPS Time'} {'Device Time'} {'Longitude'} {'Latitude'} {'GPS Speed (Meters/second)'} {'Horizontal Dilution of Precision'} {'Altitude'} {'Bearing'} {'G(x)'} {'G(y)'} {'G(z)'} {'G(calibrated)'} {'0-100kph Time(s)'} {'Absolute Throttle Position B(%)'} {'Acceleration Sensor(Total)(g)'} {'Acceleration Sensor(X axis)(g)'} {'Acceleration Sensor(Y axis)(g)'} {'Acceleration Sensor(Z axis)(g)'} {'Accelerator PedalPosition D(%)'} {'Accelerator PedalPosition E(%)'} {'Accelerator PedalPosition F(%)'} {'Actual engine % torque(%)'} {'Air Fuel Ratio(Commanded)(:1)'} {'Ambient air temp(°C)'} {'Average trip speed(whilst moving only)(km/h)'} {'Average trip speed(whilst stopped or moving)(km/h)'} {'Barometric pressure (from vehicle)(psi)'} {'CO₂ in g/km (Average)(g/km)'} {'DPF Pressure(psi)'} {'DPF Temperature(°C)'} {'Engine Coolant Temperature(°C)'} {'Engine kW (At the wheels)(kW)'} {'Engine Load(%)'} {'Engine Load(Absolute)(%)'} {'Engine Oil Temperature(°C)'} {'Engine reference torque(Nm)'} {'Engine RPM(rpm)'} {'Fuel cost (trip)(cost)'} {'Fuel flow rate/hour(gal/hr)'} {'Fuel flow rate/minute(gal/min)'} {'Fuel Remaining (Calculated from vehicle profile)(%)'} {'Fuel Trim Bank 1 Long Term(%)'} {'Fuel trim bank 1 sensor 1(%)'} {'Fuel trim bank 1 sensor 2(%)'} {'Fuel Trim Bank 1 Short Term(%)'} {'GPS Accuracy(m)'} {'GPS Altitude(m)'} {'GPS Bearing(°)'} {'GPS Latitude(°)'} {'GPS Longitude(°)'} {'GPS Satellites'} {'GPS vs OBD Speed difference(km/h)'} {'Horsepower (At the wheels)(hp)'} {'Intake Air Temperature(°C)'} {'Intake Manifold Pressure(psi)'} {'Kilometers Per Litre(Instant)(kpl)'} {'Kilometers Per Litre(Long Term Average)(kpl)'} {'Litres Per 100 Kilometer(Long Term Average)(l/100km)'} {'Miles Per Gallon(Instant)(mpg)'} {'Miles Per Gallon(Long Term Average)(mpg)'} {'O2 Volts Bank 1 sensor 1(V)'} {'O2 Volts Bank 1 sensor 2(V)'} {'Relative Throttle Position(%)'} {'Run time since engine start(s)'} {'Speed (GPS)(km/h)'} {'Speed (OBD)(km/h)'} {'Throttle Position(Manifold)(%)'} {'Timing Advance(°)'} {'Torque(Nm)'} {'Trip average KPL(kpl)'} {'Trip average Litres/100 KM(l/100km)'} {'Trip average MPG(mpg)'} {'Trip Distance(km)'} {'Trip Time(Since journey start)(s)'} {'Trip time(whilst moving)(s)'} {'Trip time(whilst stationary)(s)'} {'Turbo Boost & Vacuum Gauge(psi)'} {'Turbo Pressure Control(psi)'} {'Voltage (Control Module)(V)'} {'Voltage (OBD Adapter)(V)'} {'Volumetric Efficiency (Calculated)(%)'}
T1 = table((1:16)', VN(1:16)'); % Show Column Numbers & Labels
T2 = table(16+(1:16)', VN(16+(1:16))'); % Show Column Numbers & Labels
T3 = table(2*16+(1:16)', VN(2*16+(1:16))'); % Show Column Numbers & Labels
T4 = table(3*16+(1:16)', VN(3*16+(1:16))'); % Show Column Numbers & Labels
T5 = table(4*16+(1:16)', VN(4*16+(1:16))'); % Show Column Numbers & Labels
T6 = table(81, VN(81)); % Show Column Numbers & Labels
VN14 = VN{14}
VN14 = 'Absolute Throttle Position B(%)'
VN15 = VN{15}
VN15 = 'Acceleration Sensor(Total)(g)'
DeviceTime=sample{:,2};
acc=sample{:,15};
throttle=sample{:,14};
fuel_rate=sample{:,39};
figure
plot(DeviceTime,throttle);
hold on;
top=0.1;
[pks,locs]=findpeaks(throttle,"MinPeakHeight",top);
plot(DeviceTime(locs),pks,"ro")
hold off
xlabel("time");
ylabel("throttle position");
title("Time vs Throttle");% I can able to plot upto here. Here onwards I am getting error.
avg_pks=mean(pks);
avg_speed = sample{:,25};
mean_spd = sample{:,5};
fuel_ratePm = sample{:,40};
fuel_rate=(3.7854*fuel_rate)/60;
trip_avg_val=sample{:,70};
trip_avg=sum(trip_avg_val,'all')/length(trip_avg_val);
figure
plot(DeviceTime,avg_speed)
hold on
plot(DeviceTime,mean_spd,"ro")
hold off
xlabel('time');
ylabel('KmpH');
title('AVERAGE SPEED PLOT');
.
  4 Comments
Star Strider
Star Strider on 21 May 2021
@Shoaib Ahmed Omit the 'VariableNamingRule' name-value pair. The readtable function will issue a Warning each time about the variable names having been changed to valid MATLAB variable names. (The first appearance of allowing variable names to be read and referred to without changing them was introduced in R2019b as 'PreserveVariableNames'.)
I add the 'VariableNamingRule' name-value pair automatically when using the MATLAB Answers Run feature (that uses R2021a) to avoid the Warning showing up in the code that I post and run here.

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Tags

Products


Release

R2018a

Community Treasure Hunt

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

Start Hunting!