create account

Linear Transformation Contest: Sample Code in Matlab by dexterdev

View this thread on: hive.blogpeakd.comecency.com
· @dexterdev · (edited)
$12.82
Linear Transformation Contest: Sample Code in Matlab
Here I will post my sample code corresponding to the running [contest on linear transformation](https://steemit.com/steemstem/@dexterdev/linear-transformations-a-20-sbd-coding-contest-announcement).

```
clear  %clear all variables from matlab memory workspace
close all % close all figure windows (like previous plots)
clc % clear the screen

%% This section just creates a square 2D mesh of vectors
[X Y] = meshgrid(-10:1:10); % coordinates for vector positions
VX = X; % X,Y components of vector
VY = Y;
quiver(X, Y, VX, VY, 2)
title('Input: The 2D space')
axis square

%% reshaping the vectors for linear transformation
YY=reshape(VY,[1 21*21]);
XX=reshape(VX,[1 21*21]);
XY=[XX ;YY];

A=[1 2;-0.5 1]; % Our transformation matrix A
XY_t=A*XY; % linear transform operation

%% This section just creates a "transformed" 2D mesh of vectors
X_t=reshape(XY_t(1,:),[21 21]);
Y_t=reshape(XY_t(2,:),[21 21]);
figure
quiver(X_t, Y_t, VX, VY, 2)
axis square
title('Output: The transformed 2D space')

```

***Don't use modified versions of this code as a solution! (A friendly warning.)***

The input and output of the code is given below:
### Input
<center>![](https://i.imgur.com/JpJyGWr.png)</center>


### Output
The transformation matrix considered is
***A=***
```
1      2
-0.5   1
```

<center>![o.png](https://steemitimages.com/DQmXjtTFdSQnr76QoFo8JDPjXnRrLqwyudFFx3vLgxgeSW3/o.png)</center>

## Yes I have copy-pasted my code from github!
Don't blame me for plagiarism because I have uploaded it yesterday in [github](https://raw.githubusercontent.com/dexterdev/STEEMIT/master/CONTESTS/linear_transformation.m). 

I am tagging #steemstem because this contest comes as a part of Linear algebra article I wrote recently. So I don't expect #steemstem vote for this. See those articles below:

- [Linear Transformations: A 20 SBD coding contest announcement!](https://steemit.com/steemstem/@dexterdev/linear-transformations-a-20-sbd-coding-contest-announcement)
- [Eigen Values and Eigen Vectors: Visually Explained!
](https://steemit.com/steemstem/@dexterdev/eigen-values-and-eigen-vectors-visually-explained)


---

### Join #steemSTEM
Join the active science community #steemSTEM at discord: https://discord.gg/BZXkmWw

#### And to steemSTEM beginners:
You can ask for help in our discord page. There are people ready to help you there.

<center>https://steemitimages.com/DQmPtnKZW6cQWBAzpA8yiqTDXSsVH9zEUyxFiek2kGEoA8g/bear.gif</center>
<center>gif courtesy: @rocking-dave</center>


---

**All images without image sources are my creations :)**


## <center>Follow me @dexterdev</center>

---

     ____ _______  ______ _________ ____ ______    
    /  _ /  __\  \//__ __/  __/  __/  _ /  __/ \ |\
    | | \|  \  \  /  / \ |  \ |  \/| | \|  \ | | //
    | |_/|  /_ /  \  | | |  /_|    | |_/|  /_| \// 
    \____\____/__/\\ \_/ \____\_/\_\____\____\__/
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 60 others
properties (23)
authordexterdev
permlinklinear-transformation-contest-sample-code-in-matlab
categorysteemstem
json_metadata{"tags":["steemstem","contest","coding-challenge","coding","busy"],"users":["rocking-dave","dexterdev"],"image":["https://i.imgur.com/JpJyGWr.png","https://steemitimages.com/DQmXjtTFdSQnr76QoFo8JDPjXnRrLqwyudFFx3vLgxgeSW3/o.png","https://steemitimages.com/DQmPtnKZW6cQWBAzpA8yiqTDXSsVH9zEUyxFiek2kGEoA8g/bear.gif"],"links":["https://steemit.com/steemstem/@dexterdev/linear-transformations-a-20-sbd-coding-contest-announcement","https://raw.githubusercontent.com/dexterdev/STEEMIT/master/CONTESTS/linear_transformation.m","https://steemit.com/steemstem/@dexterdev/eigen-values-and-eigen-vectors-visually-explained","https://discord.gg/BZXkmWw"],"app":"steemit/0.1","format":"markdown"}
created2018-04-03 14:24:51
last_update2018-04-03 15:11:15
depth0
children2
last_payout2018-04-10 14:24:51
cashout_time1969-12-31 23:59:59
total_payout_value9.890 HBD
curator_payout_value2.925 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length2,855
author_reputation17,771,704,061,240
root_title"Linear Transformation Contest: Sample Code in Matlab"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id48,126,856
net_rshares4,200,787,314,740
author_curate_reward""
vote details (124)
@steemitboard ·
Congratulations @dexterdev! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

[![](https://steemitimages.com/70x80/http://steemitboard.com/notifications/voted.png)](http://steemitboard.com/@dexterdev) Award for the number of upvotes received

Click on any badge to view your own Board of Honor on SteemitBoard.

To support your work, I also upvoted your post!
For more information about SteemitBoard, click [here](https://steemit.com/@steemitboard)

If you no longer want to receive notifications, reply to this comment with the word `STOP`

> Upvote this notification to help all Steemit users. Learn why [here](https://steemit.com/steemitboard/@steemitboard/http-i-cubeupload-com-7ciqeo-png)!

Do not miss the [last announcement](https://steemit.com/easter/@steemitboard/celebrate-easter-with-steemitboard-the-eggs-opened-and-guess-what-popped-out) from @steemitboard!
properties (22)
authorsteemitboard
permlinksteemitboard-notify-dexterdev-20180403t231253000z
categorysteemstem
json_metadata{"image":["https://steemitboard.com/img/notifications.png"]}
created2018-04-03 23:12:51
last_update2018-04-03 23:12:51
depth1
children0
last_payout2018-04-10 23:12:51
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length911
author_reputation38,975,615,169,260
root_title"Linear Transformation Contest: Sample Code in Matlab"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id48,197,468
net_rshares0
@steemstem-bot ·
<center><a href="www.steemit.com/@steemstem"><img src="https://media.discordapp.net/attachments/384404201544876032/405507994583957505/steemSTEM.png"></a><br><table><tr><th> </th><th> </th><th><a href="https://steemit.com/steemstem/@steemstem/helpful-guidelines-for-crafting-steemstem-content">Guidelines</a></th><th><a href="https://steemit.com/steemstem/@steemstem/steemstem-winter-2017-2018-project-update">Project Update</a></th><th> </th><th> </th></tr></table><br><a href="https://steemit.com/steemstem/@steemstem/being-a-member-of-the-steemstem-community"><b>Being A SteemStem Member</b></a></center>
properties (22)
authorsteemstem-bot
permlinkre-linear-transformation-contest-sample-code-in-matlab-20180404t235525
categorysteemstem
json_metadata""
created2018-04-04 23:55:27
last_update2018-04-04 23:55:27
depth1
children0
last_payout2018-04-11 23:55:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length606
author_reputation3,811,533,615,496
root_title"Linear Transformation Contest: Sample Code in Matlab"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id48,384,037
net_rshares0