-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
session 06 and link to easily find main session site
- Loading branch information
1 parent
54dbfad
commit b6f6694
Showing
7 changed files
with
74 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
--- | ||
title: "Session 06 - Solving a system of linear equations" | ||
layout: post | ||
date: 2017-12-07 10:00 | ||
image: false | ||
headerImage: false | ||
tag: | ||
- Programming Sessions | ||
- Fitting | ||
- Least-squares solution | ||
- System of linear equations | ||
- Spectral unmixing | ||
star: false | ||
category: blog | ||
author: rafa | ||
description: Supporting material for the programming session 05 | ||
hidden: true | ||
externalLink: true | ||
--- | ||
|
||
During this session, we will concentrate on solving a system of linear equations | ||
|
||
$$ | ||
A*x = y | ||
$$ | ||
|
||
using the ```mldivide()``` function . We will use it to do some very basic spectral unmixing. Basically, we will decompose a mixed fluorescence spectra (containing 2 known species) into its constituent spectra, and find the relative ratio between the species. | ||
|
||
# Solving a system of linear equations in MATLAB | ||
|
||
MATLAB has many tools to help you solve a system of linear equations: [see this link](https://mathworks.com/help/matlab/math/systems-of-linear-equations.html). During this session we will concentrate on the function ```mldivide()```. In particular we will see how to handle the case when $$A$$ is a rectangular m-by-n matrix with m not equal to n, and $$y$$ is a matrix with m rows, then ```mldivide(A,y)``` returns a least-squares solution to the system of equations: | ||
$$ | ||
A*x = y | ||
$$ | ||
|
||
## Mix of 2 fluorescence spectra | ||
Let us consider the case of two species, A and B, that are able to fluoresce and have distinct emission spectra: $$S_A$$ and $$S_B$$ . If we were to measure a mix of these two species then we would obtain a total spectra $$S_{tot}$$ which is: | ||
|
||
$$ | ||
S_{tot} = c_1 S_A + c_2 S_B | ||
$$ | ||
|
||
Therefore we can use ```mldivide()``` to find $$c_1$$ and $$c_2$$ given a measured spectra $$S_{tot}$$ . We just have to understand that: | ||
1. $$S_{tot}$$ corresponds to our $$y$$ vector with dimensions m-by-1. | ||
2. Matrix A can be built by placing $$S_a$$ and $$S_b$$ as its columns, to obtain a m-by-2 matrix. | ||
|
||
Therefore, we just have to do: | ||
``` | ||
C = mldivide(A,y) | ||
``` | ||
to obtain a 2-by-1 vector C that contains the coefficients $$c_1$$ and $$c_2$$. | ||
|
||
## Supporting material | ||
|
||
[Link to the code of the session](https://github.com/CamachoDejay/ProgrammingSessions/tree/master/Session-06) | ||
|
||
[**Back to main Programming Sessions' site**](/programmingsessions) |