Documentation for beginner about MatLab | MATLAB | Forum

Avatar

Please consider registering
Guest

Search

— Forum Scope —






— Match —





— Forum Options —





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

Register Lost password?
sp_Feed sp_TopicIcon
Documentation for beginner about MatLab
Avatar
kvv213

Gold
Forum Posts: 28
sp_UserOfflineSmall Offline
1
August 24, 2016 - 3:47 am
sp_Permalink sp_Print

Dear All,

It seems that I like ThingSpeak service very much but as usually I want to get a little bit more than the standart functionality can offer. For example I colled data from a Gas Meter and do that with real digits. That means that every single update increases number. And always I can see my Gas meter actual values. But I also would like to get momentum values of consumtion with slices 15 or 60 minutes. 

In that case I need to get data from my channel and substract every value precedessor from the current value. Then, as I guess, I need to put these substracted values to a new channel (or field) and build a graph that will show me real consumption for every time period.

But the problem is that I don't understand the principles how MatLab (Analyst mostly). And can't route my work into the right direction. Where can I read something on order to understand the language principles, sintaxsys and other core things of the used languages?

Avatar
jvasudev

Forum Posts: 12
sp_UserOfflineSmall Offline
2
August 25, 2016 - 5:25 pm
sp_Permalink sp_Print sp_EditHistory

Hi,

I am not sure if I understand 100% about what you want to achieve, nevertheless I will try to provide my suggestions.

  • Create/Open a MATLAB Analysis app.
  • Use the thingSpeakRead function in the MATLAB Analysis to read data from your channel that contains the Gas meter actual values.
  • Use the diff function in MATLAB to substract every value precedessor from the current value. (there are also other similar arithmetic MATLAB functions that you can find in this page)
  • Use the thingSpeakWrite function to write the values back into a new a channel. 

There are many built-in MATLAB functions for using basic descriptive statistics. Also, since now ThingSpeak supports MATLAB Toolboxes, you can use advanced MATLAB functions that belong to these toolboxes - some examples of using functions from these toolboxes in ThingSpeak can be found here.

If you are looking to learn MATLAB from the basics, you can visit the MATLAB Getting Started page which has links to nice tutorials of how to get started using MATLAB. Also, you have the MATLAB Central where you can ask MATLAB users and get responses for any MATLAB related questions that you may have. And you can visit the MATLAB File Exchange to find MATLAB code that other MATLAB users have posted that may help you. 

Avatar
kvv213

Gold
Forum Posts: 28
sp_UserOfflineSmall Offline
3
August 26, 2016 - 4:48 am
sp_Permalink sp_Print

jvasudev said

If you are looking to learn MATLAB from the basics, you can visit the MATLAB Getting Started page which has links to nice tutorials of how to get started using MATLAB. Also, you have the MATLAB Central where you can ask MATLAB users and get responses for any MATLAB related questions that you may have. And you can visit the MATLAB File Exchange to find MATLAB code that other MATLAB users have posted that may help you.   

thank you very much, will try to use these suggestions!

Avatar
kvv213

Gold
Forum Posts: 28
sp_UserOfflineSmall Offline
4
October 7, 2016 - 4:18 am
sp_Permalink sp_Print sp_EditHistory

jvasudev said
Hi,

I am not sure if I understand 100% about what you want to achieve, nevertheless I will try to provide my suggestions.

  

Hello jvasudev,

I've manage to realize two new grpahs using ThingSpeak MATLAB Analysis apps. The first app reads twice values from one field and calculates difference between two values in hour time. The pbolem here that not every record in the original field contains data. I update the original channel with 8 fields but not all of them have values at the time of update. So here I get hourly consumption of my gas. And I write it to a new channel.

The second app does a little bit different work. It calculates momentum consumption. It uses diff function (I hope that this is a function) and the result is written to a new field. If there are some NaN values that is OK. As I understand from the description they are processed correctly by diff function.

So, now I have two new fields with consumption values (hourly and momentum). But I'd like to generate bars graph not ordinary grpah. Is it possible with ThingSpeak somehow?

Update: I think that I'll be able to do so with MATLAB Visualization app 🙂

 

PS. Here are two usefull links for MATLAB and ThingSpeak online reference manuals:

http://www.mathworks.com/help/matlab/functionlist.html

http://www.mathworks.com/help/thingspeak/functionlist.html

They helped me very much.

Avatar
Meenakshi

Forum Posts: 8
sp_UserOfflineSmall Offline
5
October 7, 2016 - 6:31 pm
sp_Permalink sp_Print

You are right. You can use MATLAB Visualization app.

checkout 'bar' function from MATLAB: https://www.mathworks.com/help/matlab/ref/bar.html

In the following article, refer 'Looking at Weekly Sums for Eastbound and Westbound Traffic and Plotting' section to learn more about plotting bar graphs: 

http://makerzone.mathworks.com/blog/counting-cars-and-analyzing-traffic-raspberry-pi-thingspeak/

Hope this helps. Feel free to share your final Visualization. 

Avatar
kvv213

Gold
Forum Posts: 28
sp_UserOfflineSmall Offline
6
October 11, 2016 - 11:38 am
sp_Permalink sp_Print sp_EditHistory

Meenakshi said
You are right. You can use MATLAB Visualization app.

checkout 'bar' function from MATLAB: https://www.mathworks.com/help/matlab/ref/bar.html

In the following article, refer 'Looking at Weekly Sums for Eastbound and Westbound Traffic and Plotting' section to learn more about plotting bar graphs: 

http://makerzone.mathworks.com/blog/counting-cars-and-analyzing-traffic-raspberry-pi-thingspeak/

Hope this helps. Feel free to share your final Visualization.   

Thank you for the good example. I'm already managed to use bar grpah and get something like this:

https://i2.wp.com/s017.radikal.ru/i443/1610/2b/ccbc83d4f066.png?w=100Image Enlarger

 

 

I use the following code:

figure
bar(timeStamp, GasImpNow);
xlabel('Время');
ylabel('Потребление, кб. м.');
title('Потребление газа за последние 24 часа');
ax=gca;
%set(gca,'XTickLabel', timeStamp);
grid on

But the graph doesn't look pretty. The bars are too thin and the date labels are not very informative. But I can't impruve it easily. If I use XTickLabel I need to convert timeStamp into Strings and I receive just empthy graph. I also tried to collapse timeStamp into only hours because I use 24 hours graph frame but with no success.

 

The hard way is to process all the data into a much simplified data. Where I collect all the data into hour frames or something like this. 

Forum Timezone: America/New_York

Most Users Ever Online: 114

Currently Online:
27 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

rw950431: 252

Vinod: 164

cstapels: 96

piajola: 75

vespapierre: 63

Adarsh_Murthy: 59

Newest Members:

dannymm1

KamorkasOr

GRV2903

Jusikaclaiz

Raymondpoers

ScottDus

Forum Stats:

Groups: 4

Forums: 17

Topics: 1313

Posts: 4565

 

Member Stats:

Guest Posters: 1

Members: 5703

Moderators: 0

Admins: 2

Administrators: Hans, lee