我正在使用这个生成的代码绘制两个向量之间的心理测量函数:
smqi=[0 0.504500000000000 0.540500000000000 0.574800000000000 0.459400000000000 0.500800000000000 0.533900000000000 0.401700000000000 0.462100000000000 0.511300000000000 0.291300000000000 0.347300000000000 0.419900000000000 0.491700000000000 0.552400000000000 0.598600000000000 0.392600000000000 0.426000000000000 0.451400000000000 0.334900000000000 0.359500000000000 0.371300000000000 0 0.640800000000000 0.760600000000000 0.847100000000000 0.336200000000000 0.409200000000000 0.463000000000000 0.357600000000000 0.437700000000000 0.504400000000000 0.421200000000000 0.500200000000000 0.579800000000000 0.452700000000000 0.557200000000000 0.592200000000000 0.314800000000000 0.313800000000000 0.344800000000000 0.315500000000000 0.348300000000000 0.355400000000000 0 0.558100000000000 0.636700000000000 0.702900000000000 0.361500000000000 0.427100000000000 0.469100000000000 0.389700000000000 0.457700000000000 0.489800000000000 0.446800000000000 0.528700000000000 0.589200000000000 0.441500000000000 0.475300000000000 0.499600000000000 0.325500000000000 0.360700000000000 0.364200000000000 0.338400000000000 0.368200000000000 0.396200000000000 0 0.702500000000000 0.813100000000000 0.995500000000000 0.370600000000000 0.476800000000000 0.594300000000000 0.355200000000000 0.452000000000000 0.528500000000000 0.484000000000000 0.567400000000000 0.671500000000000 0.454000000000000 0.460700000000000 0.469600000000000 0.299900000000000 0.318300000000000 0.361900000000000 0.264800000000000 0.263000000000000 0.279500000000000];
MOS=[0.240085000000000 0.558541000000000 0.861963000000000 0.935125000000000 0.276903000000000 0.634308000000000 0.838878000000000 0.268853000000000 0.274772000000000 0.724518000000000 0.285545000000000 0.238901000000000 0.477684000000000 0.338700000000000 0.655736000000000 0.656328000000000 0.138511000000000 0.388422000000000 0.582929000000000 0.368178000000000 0.364626000000000 0.341423000000000 0.237362000000000 0.728069000000000 0.894282000000000 1 0.348526000000000 0.689712000000000 0.712087000000000 0.473541000000000 0.558778000000000 0.600331000000000 0.480052000000000 0.638688000000000 0.924944000000000 0.349947000000000 0.765834000000000 0.826684000000000 0.279507000000000 0.315852000000000 0.529892000000000 0.193678000000000 0.282112000000000 0.375873000000000 0.266012000000000 0.536285000000000 0.739079000000000 0.924825000000000 0.362969000000000 0.516160000000000 0.724162000000000 0.417663000000000 0.649461000000000 0.682846000000000 0.540784000000000 0.823606000000000 0.900438000000000 0.277850000000000 0.318693000000000 0.433763000000000 0.221617000000000 0.281165000000000 0.381674000000000 0.141352000000000 0.335740000000000 0.391263000000000 0 0.659879000000000 0.834853000000000 0.953475000000000 0.502664000000000 0.609921000000000 0.818042000000000 0.402155000000000 0.543270000000000 0.755890000000000 0.470700000000000 0.621996000000000 0.748905000000000 0.375873000000000 0.501243000000000 0.682254000000000 0.126080000000000 0.294779000000000 0.353972000000000 0.223748000000000 0.369599000000000 0.261276000000000];
function [fitresult, gof] = createFit(smqi, mos)
%CREATEFIT(SMQI,MOS)
% Create a fit.
%
% Data for 'untitled fit 1' fit:
% X Input : smqi 1x88
% Y Output: mos 1x88
% Output:
% fitresult : a fit object representing the fit.
[xData, yData] = prepareCurveData(smqi, mos);
% Set up fittype and options.
ft = fittype( 'erfc((a+b*x)/sqrt(2))/2', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Algorithm = 'Levenberg-Marquardt';
opts.Display = 'Off';
opts.StartPoint = [0.83763959965349 0.463660782983039];
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, xData, yData );
legend( h, 'mos vs. smqi', 'untitled fit 1', 'Location', 'NorthEast' );
% Label axes
xlabel smqi
ylabel mos
grid on
我想为每组22个矢量SMQI和MOS值指定不同的标记,同时保留相同的行(fitresult
)。
我负责分散功能,但我没有成功解决这个问题。
帮助?
答案 0 :(得分:0)
最简单的方法是将xData
和yData
变量重塑为[X x 4],然后将这些变量传递给绘图,为每个组创建单独的绘图对象。然后,您可以根据需要设置标记。
xData = reshape(xData, [], 4);
yData = reshape(yData, [], 4);
p = plot(xData, yData, '.');
set(p, {'Marker'}, {'.'; 'o'; 'x'; '*'})
hold on
plot(fitresult);