introduction to programming with matlab - Vanderbilt University week-9 assignment 1 solutions

 Excel Files

These solutions are for reference only.

It is recommended that you should solve the assignment and quiz by yourself honestly then only it makes sense to complete the course.

but if you cant figure out some part of it than you can refer these solutions

make sure you understand the solution  

dont just copy paste it

-----------------------------------------

function distance = get_distance(x,y) persistent raw; if isempty(raw) [~, ~, raw] = xlsread('Distances.xlsx'); end state1_index = state2index(raw, x); state2_index = state2index(raw, y); if state1_index > 1 && state2_index > 1 distance = cell2mat(raw(state1_index, state2_index)); else distance = -1; end end function index = state2index(raw, state) [~, states] = size(raw); index = -1; for i = 2:states if strcmp(cell2mat(raw(1, i)), state) index = i; end end end



main course : https://www.coursera.org/learn/matlab

No comments

darkmode