# Dragon Notes

UNDER CONSTRUCTION
Latest content:
 Feb 20 Regression - Data Science Feb 19 +Classification - ML Feb 18 Control Design - Control Sys. Feb 16 Solved Problems - Data Sci. Feb 12 +Control Systems - MATLAB Feb 10 Image Recognition - Digits:ML Algorithms

# MATLAB vs. R

Arrays, Vectors, Matrices

 MATLAB R >> arr = zeros(2,3) >> vec = [1 4 9 16] >> mtx = [1 2 3; 4 5 6] >> mtx(2,3), mtx(1,:) >> size(mtx,1), size(mtx,2) >> {0,rand(2),'Greets',{'Cell','ception'}}  > arr = array(0, dim = c(2,3)) # 'dim =' omittable > vec = c(1,4,9,16) > mtx = array(c(c(1,2,3),c(4,5,6)), c(2,3)) # or, mtx = matrix(c(1,2,3,4,5,6), 2, 3, 1) # '1' arranges by row > mtx[2,3], mtx[1,] > nrow(mtx), ncol(mtx) > data.frame(c1=0,c2=runif(2),c3='Greets',c4=c('Cell','ception')) % not exactly same as MATLAB's; execute both to compare 

Plots

 MATLAB R >> t = 0:.1:10; y = sin(t); plot(t,y) 'green' / 'g' LineWidth Marker = 'x' >> xlabel, ylabel  > t = seq(0,10,.1) y = sin(t) plot(t,y,'l') # default = scatter col = 'green' lwd pch = 'x'; try plot(1:20,1:20,pch =1:20) > xlab, ylab 

General

 MATLAB R >> clc >> clear all >> clear x >> keepvars = {'x','y'} clearvars('-except', keepvars{:}); >> pwd >> cd(dir)  > [Ctrl] + [L] # key presses > rm(list=ls()) > rm(x) > keepvars = c('x','y') rm(list=setdiff(ls(), keepvars)) > getwd() > setwd(dir) # use '/' instead of '\'