1330 0

[Weka及其他] MATLAB课程:代码示例之Mathematics(二) [推广有奖]

企业贵宾

已卖:160份资源

巨擘

0%

还不是VIP/贵宾

-

威望
4
论坛币
624047 个
通用积分
180.4857
学术水平
918 点
热心指数
987 点
信用等级
841 点
经验
399143 点
帖子
9786
精华
48
在线时间
17322 小时
注册时间
2014-8-19
最后登录
2022-11-2

楼主
widen我的世界 学生认证  发表于 2016-3-7 12:38:34 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

MATLAB课程:代码示例之Mathematics(二)


Integer Arithmetic


This example shows how to perform arithmetic on integer data representing signals and images.


Load Integer Signal Data

Load measurement datasets comprising signals from four instruments using 8 and 16-bit A-to-D's resulting in data saved as int8, int16 and uint16. Time is stored as uint16.

load integersignal% Look at variableswhos Signal1 Signal2 Signal3 Signal4 Time1


  Name            Size            Bytes  Class     Attributes  Signal1      7550x1              7550  int8                  Signal2      7550x1              7550  int8                  Signal3      7550x1             15100  int16                 Signal4      7550x1             15100  uint16                Time1        7550x1             15100  uint16              


Plot Data

First we will plot two of the signals to see the signal ranges.

plot(Time1, Signal1, Time1, Signal2);grid;legend('Signal1','Signal2');


Here we see the values for int8. It is likely that these values would need to be scaled to calculate the actual physical value that the signal represents e.g. Volts.

Process Data

We can perform standard arithmetic on integers such as +, -, *, and /. Let's say we wished to find the sum of Signal1 and Signal2.

SumSig = Signal1 + Signal2; % Here we sum the integer signals.


Now let's plot the sum signal and see where it saturates.

cla;plot(Time1, SumSig);hold onSaturated = (SumSig == intmin('int8')) | (SumSig == intmax('int8')); % Find where it has saturatedplot(Time1(Saturated),SumSig(Saturated),'rd')gridhold off


The markers show where the signal has saturated.

Load Integer Image Data

Next we will look at arithmetic on some image data.

street1 = imread('street1.jpg'); % Load image datastreet2 = imread('street2.jpg');whos street1 street2


  Name           Size                Bytes  Class    Attributes  street1      480x640x3            921600  uint8                street2      480x640x3            921600  uint8              


Here we see the images are 24-bit color, stored as three planes of uint8 data.

Display Images

Display first image.

cla;image(street1); % Display imageaxis equalaxis off


Display second image

image(street2); % Display imageaxis equalaxis off


Scale an Image

We can scale the image by a double precision constant but keep the image stored as integers. For example,

duller = 0.5 * street2; % Scale image with a double constant but create an integerwhos duller


  Name          Size                Bytes  Class    Attributes  duller      480x640x3            921600  uint8              


subplot(1,2,1);image(street2);axis off equal tighttitle('Original');  % Display imagesubplot(1,2,2);image(duller);axis off equal tighttitle('Duller');    % Display image


Add the Images

We can add the two street images together and plot the ghostly result.

combined = street1 + duller; % Add |uint8| imagessubplot(1,1,1)cla;image(combined); % Display imagetitle('Combined');axis equalaxis off




二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:mathematics Mathematic MATLAB课程 Thematic MATLAB MATLAB课程 代码示例 Mathematics(二) Integer Arithmetic


https://www.cda.cn/?seo-luntan
高薪就业·数据科学人才·16年教育品牌

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-26 20:52