Undefined operator '>' for input arguments of type 'cell'. | MATLAB IoT Analytics | Forum

The ThingSpeak community site has been upgraded to a new site. This site is currently in read-only mode. You can ask questions or post and read discussions on the new site.
Avatar

Lost password?
Advanced Search

— Forum Scope —






— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed sp_TopicIcon
Undefined operator '>' for input arguments of type 'cell'.
No permission to create posts
October 4, 2016
1:53 am
Avatar
rw950431

Top
Members
Forum Posts: 279
Member Since:
January 30, 2014
sp_UserOfflineSmall Offline

I have the following code in a matlab visualisation which used to work fine. However in the last few days the data source has had problems and now my matlab code complains "Undefined operator '>' for input arguments of type 'cell'."

 

readChannelID = [150393];

%% Read Data %%

% Read first data variable
power = thingSpeakRead(readChannelID, 'OutputFormat','table' , 'NumDays', 3)

%% Visualize Data %%
dates=datenum(power.Timestamps);
price=power.Price
price(price>2000)=2000

  '-4e-05'
    '0.00014'
    '0.00014'
    '0.00014'
    '0.00014'
    '0.00014'
    '-3e-05'
    '6e-05'

 

Undefined operator '>' for input arguments of type cell.

 

I'm guessing it doesnt like the "-4e-05" type of entry.  If I reduce the time period to exclude these values it runs OK.

What can I do to clean my data so this works properly?

October 4, 2016
1:02 pm
Avatar
Adarsh_Murthy

MathWorks
Members
Forum Posts: 62
Member Since:
August 25, 2015
sp_UserOfflineSmall Offline

You are right, it looks like data represented in exponential format is leading the column to be represented as a string. Couple options to resolve the error:

 

1. Manually convert the data in Price column to double datatype. Here is some example code:

 

readChannelID = [150393];
%% Read Data %%
% Read first data variable
power = thingSpeakRead(readChannelID, 'OutputFormat','table' , 'NumDays', 3)
%% Visualize Data %%
dates=datenum(power.Timestamps);
price = cellfun(@str2num, power.Price);
price(price>2000)=2000 

 

The cellfun() function call is used to apply the str2num() function to all elements of the Price column. You can find more information about cellfun and str2num functions at the following link:

https://www.mathworks.com/help/matlab/ref/cellfun.html

https://www.mathworks.com/help/matlab/ref/str2num.html

 

2. Update your source to send data to ThingSpeak in a non-exponential format.

 

We will look into options to update the thingSpeakRead function to handle exponential data representation.

 

Thanks! 

October 4, 2016
8:28 pm
Avatar
rw950431

Top
Members
Forum Posts: 279
Member Since:
January 30, 2014
sp_UserOfflineSmall Offline

Thanks Adarsh, cellfun() works perfectly.

Forum Timezone: America/New_York

Most Users Ever Online: 166

Currently Online:
22 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 272

Vinod: 240

piajola: 95

turgo: 70

vespapierre: 63

Adarsh_Murthy: 62

Member Stats:

Guest Posters: 1

Members: 8665

Moderators: 1

Admins: 2

Forum Stats:

Groups: 3

Forums: 14

Topics: 1600

Posts: 5760

Newest Members:

kusmumichael, petersmith99, Rambant, blakeharriss09, optisol, Niyonzima Fils

Moderators: cstapels: 460

Administrators: Hans: 405, lee: 457