MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

### Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

# Solution 115063

Submitted on 19 Jul 2012 by Richard Zapor

Correct

11Size
This is the leading solution.
`This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.`

### Test Suite

Test
Code Input and Output
1
Pass

```%%
% The AVIRIS fileread info is at the bottom
% Solution Hint:
% The Matrix hint is inv(S'S)(S'S)=I
% With g=Sf multiply both sides by h'
% S'g=S'Sf, now multiply both sides by inv(S'S)
% inv(S'S)(S'g)=inv(S'S)(S'S)f which is I*f
% Now simplify the right side and there is a solution
% Solution Bigger/Better Hint: Search on mldivide
```

2
Pass

```%%
global S
%http://tinyurl.com/matlab-hyper-spectra
%http://rmatlabtest.appspot.com/Spectra.mat
urlwrite('http://rmatlabtest.appspot.com/Spectra.mat','Spectra.mat') ;
load('Spectra.mat'); % S is the variable in Spectra.mat
f_exp=[.5 .5 0 0 0 0 0 0 0 ]';
g=S*f_exp;
f = hyperspectral(g,S);
assert(isequal(round(100*f)/100,f_exp),sprintf('%f\n',f))
```

3
Pass

```%%
global S
f_exp=[0 .5 0.25 0 0 0 0.25 0 0 ]';
g=S*f_exp;
f = hyperspectral(g,S);
assert(isequal(round(100*f)/100,f_exp),sprintf('%f\n',f))
```

4
Pass

```%%
global S
f_exp=[0 .25 0.6 0 0 0 0 0.15 0 ]';
g=S*f_exp;
f = hyperspectral(g,S);
assert(isequal(round(100*f)/100,f_exp),sprintf('%f\n',f))
```

5
Pass

```%%
%
%Reading of the full Moffett Field file: (8GB RAM recommended)
% The file is 600MB
%cd 'C:\Users\???' % Your file location
%fn='f080611t01p00r07rdn_c_sc01_ort_img'
%fid = fopen (fn,'r');
%A = int16(fread(fid, 'int16', 'ieee-be'));
%A2 = reshape (A, 224,753,1924); % Specifics found in text files
%A3 = permute (A2,[3 2 1]); % X Y Band
%figure;imagesc(squeeze(A3(:,:,1))); % To view top layer
```