⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graph.m

📁 802.11仿真源码 对分析RSSI很有用的
💻 M
字号:
function Graph(x,y,minx,maxx,weight,labelx,labely, heading, colourfit, colourxy, RSSI, PER, yes_fit)%This function ->%       Graph: Creates a plot of datasets y vs x and%           then proceeds to calculate the weigted line of best fit %               using a linear polynomial and graphs the resulted fit%                  if asked with the colour argument as follows:%       'y' = yellow, 'm' = magenta, 'c' = cyan, 'r' = red, 'g' = green,%               'b' = blue, 'w' = white or 'k' = black% Function description is:%Graph(x data, y data, weights of data, x-axis label,%   y-axis label,graph heading, the colour for the linear fit, %     colour for the data, if RSSI is used, is PER is used %       and if a fit is wanted in the created figure)fh = figure();iptsetpref('ImshowBorder','tight');legh_ = []; legt_ = {};   % handles and text for legendhold on;% --- Plot data originally in dataset "y vs. x"if(RSSI == 1)    xy = plot(x, y, '.'); axis ([minx maxx 161 230]);    set(xy,'Color',colourxy);else        xy = plot(x, y, '.'); axis ([minx maxx min(y) max(y)]);    set(xy,'Color',colourxy);end% --- Create fit fitopt = fitoptions('method','LinearLeastSquares','Weights',weight);set(fitopt,'Weight',weight);% Fit this model using new data where poly1 for a linear fit and poly'x' % for any (x + 1) order polynomialx = x(:);y = y(:);weight = weight(:);curvefit = fit(x,y,'poly1',fitopt)ci = confint(curvefit,0.95)if(yes_fit == 1)    % Plot this fit    wgt_ = plot(curvefit); axis ([minx maxx min(y) max(y)]);           set(wgt_(1),'LineWidth',2,'Color',colourfit)    % Add legend for line of Best fit    legh_(end+1) = wgt_(1);                     %point used    legt_{end+1} = 'Weighted Line of Best Fit'; %label    legend(legh_, legt_);  endhold off;%Labels for x,y and headingtitle(heading);xlabel(labelx); ylabel(labely);f_gcf = getframe(gcf); % get graphic contentimwrite(f_gcf.cdata,[heading '.jpeg']); %save content with heading as prefix

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -