Data normalization with threshold
16 次查看(过去 30 天)
显示 更早的评论
Hi, I am interested in normalizing my data between 0 and 1. However, I do have a threshold value/limit value that I would like to use while normalizing. Example: data: [10,30,50,75], threshold value: [70]. Good data is when it does not exceed 70. I am not sure how to incorporate this threshold while normalizing data. Please help
采纳的回答
Star Strider
2023-3-5
I am not certain what you want to do.
Perhaps one of these —
data = [10,30,50,75];
threshold_value = [70];
Result = normalize(data(data<=threshold_value), 'range',[0 1]) % Scale Only The Data To Be Considered
B = [70 1; 0 1] \ [1; 0]; % Scaling Parameters
Result = [data(data<=threshold_value).' ones(size(data(data<=threshold_value).'))] * B % Scale [0 70] —> [0 1]
The first scales only the data that are less than 70 to [0 1]. The second scales [0 70] to [0 1], regardless of the data, although both limit the data to [0 70].
.
20 个评论
MattC
2023-3-5
I think what I want is if there is a data point let’s say which is exactly 70 then it should be corresponding to 1 point in the normalized data. Will that be achieved with this?
Also, if I have multiple datasets like A = [10,30,50,75], B = [30,50,75,95], C = [15,35,50,75] And all 3 different values for all datasets. A_Threshold = [70], B_Threshold = [80], C_Threshold = [85]
Is it possible to achieve this on a normalized scale of [0,1] all 3 in one plot?
Star Strider
2023-3-5
I am still not certain what you want.
Try this for all of those —
Scaled = @(data,Th) [data(:) ones(size(data(:)))] * ([Th 1; 0 1] \ [1; 0]); % Scale Data By Threshold
A = [10,30,50,75];
B = [30,50,75,95];
C = [15,35,50,75];
A_Threshold = [70];
B_Threshold = [80];
C_Threshold = [85];
A_Scaled = Scaled(A,A_Threshold)
A_Scaled = 4×1
0.1429
0.4286
0.7143
1.0714
B_Scaled = Scaled(B,B_Threshold)
B_Scaled = 4×1
0.3750
0.6250
0.9375
1.1875
C_Scaled = Scaled(C,C_Threshold)
C_Scaled = 4×1
0.1765
0.4118
0.5882
0.8824
The ‘Scaled’ function scales the data [0 1] according to the provided threshold. Data greater than the threshold will have scale values greater than 1.
.
MattC
2023-3-5
I think this is what I was trying to achieve. So when we say scaled here, does it mean normalizing?
Also, I want to put this in a plot like having different colors for the 3 different datasets and different color for ones exceeding threshold is it possible to do that?
Example:
Star Strider
2023-3-5
I would definitely call this scaling, not normalising, however I doubt that it makes much of a difference.
Plotting it is straightforward.
Try omething like this —
Scaled = @(data,Th) [data(:) ones(size(data(:)))] * ([Th 1; 0 1] \ [1; 0]); % Scale Data By Threshold
A = [10,30,50,75];
B = [30,50,75,95];
C = [15,35,50,75];
A_Threshold = [70];
B_Threshold = [80];
C_Threshold = [85];
A_Scaled = Scaled(A,A_Threshold);
B_Scaled = Scaled(B,B_Threshold);
C_Scaled = Scaled(C,C_Threshold);
y = [A_Scaled, B_Scaled, C_Scaled];
x = ones(size(y,1),1)*(1:size(y,2));
rgb = 'bgr';
cmy = 'cmy';
xtl = {'A','B','C'};
cgttt = [0.9 0.5 0.3];
figure
hold on
for k = 1:size(y,2)
L = y(:,k)<=1;
hp1{k} = plot(x(L,k), y(L,k), 's', 'Color',rgb(k), 'MarkerSize', 10, 'MarkerFaceColor',rgb(k), 'DisplayName',sprintf('%s <= Threshold',xtl{k}));
hp2{k} = plot(x(~L,k), y(~L,k), 's', 'Color',cgttt, 'MarkerSize', 10, 'MarkerFaceColor',cgttt, 'DisplayName','> Threshold');
end
xlim([0 4])
set(gca, 'XTick',1:3, 'XTickLabel',xtl)
hold off
yl = yline(1, '--r', 'Threshold', 'LineWidth',2, 'DisplayName','Threshold');
legend([hp1{:} hp2{1} yl], 'Location','eastoutside')
The legend you want appears to me to be conflicting. I did my best with it.
.
MattC
2023-3-5
编辑:MattC
2023-3-5
Thank you @Star Strider. I do have a follow up question. So, the data I have is per day basis and I am trying to incorporate that into the plots.
So, let's say
%% Day 1
A = [10,30,50,75];
B = [30,50,75,95];
C = [15,35,50,75];
%% Day 2
A = [20,40,60,65];
B = [40,70,75,95];
C = [10,30,45,75];
The threholds remain the same across each day for A,B,C. There is no change in that.
- I am not sure how to make the variables A,B,C in such a way that it retains values from previous day while still adding the new day's value. I want to keep the scale dynamic for x. If there is data for day1, day2 then x axis would show that for now but when data for day 3 comes it would automatically be added to the plot
- I am trying to incorporate this in the plots for each day. So, when we have this A,B,C in the x axis that would create an issue because I cannot show this for other day.
Example of what I am trying to do is something like this: (Day 1 having A,B,C scaled values all lined up vertically instead of them spread across x axis)
Star Strider
2023-3-5
Adapting my code to multiple days was a challenge. This works for two days and three data sets. To adapt it to more days will require unique markers for the additional days.
Taking a guess, since I’m not certain what you are asking —
Scaled = @(data,Th) [data(:) ones(size(data(:)))] * ([Th 1; 0 1] \ [1; 0]); % Scale Data By Threshold
Day{1} = [10,30,50,75;
30,50,75,95;
15,35,50,75];
Day{2} = [20,40,60,65;
40,70,75,95;
10,30,45,75];
A_Threshold = 70;
B_Threshold = 80;
C_Threshold = 85;
Thrshld = [A_Threshold; B_Threshold; C_Threshold];
for k1 = 1:numel(Day)
for k2 = 1:size(Thrshld,1)
DayScaled{k1}(k2,:) = Scaled(Day{k1}(k2,:),Thrshld(k2));
end
end
Day1 = array2table([DayScaled{1}.'], 'VariableNames',{'A','B','C'});
Day2 = array2table([DayScaled{2}.'], 'VariableNames',{'A','B','C'});
ScaledResult = table(Day1,Day2, 'VariableNames',{'Day 1','Day 2'})
ScaledResult = 4×2 table
Day 1 Day 2
A B C A B C
____________________________ ____________________________
0.14286 0.375 0.17647 0.28571 0.5 0.11765
0.42857 0.625 0.41176 0.57143 0.875 0.35294
0.71429 0.9375 0.58824 0.85714 0.9375 0.52941
1.0714 1.1875 0.88235 0.92857 1.1875 0.88235
x = ones(size([Day{1}],2),1)*(1:size([Day{1}],1));
rgb = 'bgr';
cmy = 'cmy';
xtl = {'A','B','C'};
mk = {'s','d'};
cgttt = [0.9 0.5 0.3];
figure
hold on
for k1 = 1:numel(Day)
for k2 = 1:size(Thrshld,1)
y = DayScaled{k1}(k2,:);
L = y<=1;
hp1{k1,k2} = plot(x(L,k2), y(L), mk{k1}, 'Color',rgb(k2), 'MarkerSize', 10, 'MarkerFaceColor',rgb(k2), 'DisplayName',sprintf('%s \\leq Threshold, Day %d',xtl{k2},k1));
hp2{k1,k2} = plot(x(~L,k2), y(~L), mk{k1}, 'Color',cgttt, 'MarkerSize', 10, 'MarkerFaceColor',cgttt, 'DisplayName',sprintf('> Threshold Day %d',k1));
end
end
xlim([0 4])
set(gca, 'XTick',1:3, 'XTickLabel',xtl)
hold off
yl = yline(1, '--r', 'Threshold', 'LineWidth',2, 'DisplayName','Threshold');
legend([hp1{:} hp2{:,[2 3]} yl], 'Location','eastoutside')
This is the best I can do.
.
MattC
2023-3-5
编辑:MattC
2023-3-5
Thanks for help @Star Strider. I think I'll try another way because I would need it for each day and the day count can go upto a year as well which will make this approach you shared difficult
So, lets say if we only had 3 values (this is for day 1 but lets forget that because I think this is making it confusing adding days filter)
How do we plot these 3 values vertically against the threshold value 1 instead of horizontally which we have now? Can you please help?
The label for x axis should be Day1 instead of what we have A,B,C right now
A_scaled = 1.0714, B_scaled = 1.1875, C_scaled = 0.88235
Star Strider
2023-3-5
How would you plot the day count and keep the ‘A’-‘C’ as well? If you do not want to keep tha ‘A’-‘C’ designations, then plotting as a function of the days is straigtforward. Complications arise in plotting both of them, although that is a possibility as well —
Scaled = @(data,Th) [data(:) ones(size(data(:)))] * ([Th 1; 0 1] \ [1; 0]); % Scale Data By Threshold
Day{1} = [10,30,50,75;
30,50,75,95;
15,35,50,75];
Day{2} = [20,40,60,65;
40,70,75,95;
10,30,45,75];
A_Threshold = 70;
B_Threshold = 80;
C_Threshold = 85;
Thrshld = [A_Threshold; B_Threshold; C_Threshold];
for k1 = 1:numel(Day)
for k2 = 1:size(Thrshld,1)
DayScaled{k1}(k2,:) = Scaled(Day{k1}(k2,:),Thrshld(k2));
end
end
Day1 = array2table([DayScaled{1}.'], 'VariableNames',{'A','B','C'});
Day2 = array2table([DayScaled{2}.'], 'VariableNames',{'A','B','C'});
ScaledResult = table(Day1,Day2, 'VariableNames',{'Day 1','Day 2'})
ScaledResult = 4×2 table
Day 1 Day 2
A B C A B C
____________________________ ____________________________
0.14286 0.375 0.17647 0.28571 0.5 0.11765
0.42857 0.625 0.41176 0.57143 0.875 0.35294
0.71429 0.9375 0.58824 0.85714 0.9375 0.52941
1.0714 1.1875 0.88235 0.92857 1.1875 0.88235
x = ones(size([Day{1}],2),1)*(1:size([Day{1}],1));
rgb = 'bgr';
cmy = 'cmy';
xtl = {'A','B','C'};
mk = {'s','d'};
cgttt = [0.9 0.5 0.3];
figure
hold on
for k1 = 1:numel(Day)
for k2 = 1:size(Thrshld,1)
y = DayScaled{k1}(k2,:);
L = y<=1;
hp1{k1,k2} = plot(x(L,k2)+3*(k1-1), y(L), mk{k1}, 'Color',rgb(k2), 'MarkerSize', 10, 'MarkerFaceColor',rgb(k2), 'DisplayName',sprintf('%s \\leq Threshold, Day %d',xtl{k2},k1));
hp2{k1,k2} = plot(x(~L,k2)+3*(k1-1), y(~L), mk{k1}, 'Color',cgttt, 'MarkerSize', 10, 'MarkerFaceColor',cgttt, 'DisplayName',sprintf('> Threshold Day %d',k1));
end
end
xlim([0 6])
set(gca, 'XTick',1:6, 'XTickLabel',xtl)
text(2:3:6, ones(1,2)*min(ylim)-0.075*diff(ylim), compose('Day %d',1:2), 'Horiz','center', 'Vert','top')
hold off
yl = yline(1, '--r', 'Threshold', 'LineWidth',2, 'DisplayName','Threshold');
legend([hp1{:} hp2{:,[2 3]} yl], 'Location','northoutside', 'NumColumns',3, 'FontSize',8)
I encourage you to experiment with this approach. I am noit certaion how easily it scales to more days, however I will defer to you for that.
.
Star Strider
2023-3-5
‘How do we plot these 3 values vertically against the threshold value 1 instead of horizontally which we have now?’
I am not certain that I understand what you want to do.
Perhaps this —
Scaled = @(data,Th) [data(:) ones(size(data(:)))] * ([Th 1; 0 1] \ [1; 0]); % Scale Data By Threshold
Day{1} = [10,30,50,75;
30,50,75,95;
15,35,50,75];
Day{2} = [20,40,60,65;
40,70,75,95;
10,30,45,75];
A_Threshold = 70;
B_Threshold = 80;
C_Threshold = 85;
Thrshld = [A_Threshold; B_Threshold; C_Threshold];
for k1 = 1:numel(Day)
for k2 = 1:size(Thrshld,1)
DayScaled{k1}(k2,:) = Scaled(Day{k1}(k2,:),Thrshld(k2));
end
end
Day1 = array2table([DayScaled{1}.'], 'VariableNames',{'A','B','C'});
Day2 = array2table([DayScaled{2}.'], 'VariableNames',{'A','B','C'});
ScaledResult = table(Day1,Day2, 'VariableNames',{'Day 1','Day 2'})
ScaledResult = 4×2 table
Day 1 Day 2
A B C A B C
____________________________ ____________________________
0.14286 0.375 0.17647 0.28571 0.5 0.11765
0.42857 0.625 0.41176 0.57143 0.875 0.35294
0.71429 0.9375 0.58824 0.85714 0.9375 0.52941
1.0714 1.1875 0.88235 0.92857 1.1875 0.88235
x = ones(size([Day{1}],2),1)*(1:size([Day{1}],1));
rgb = 'bgr';
cmy = 'cmy';
xtl = {'A','B','C'};
mk = {'s','d'};
cgttt = [0.9 0.5 0.3];
figure
hold on
for k1 = 1:numel(Day)
for k2 = 1:size(Thrshld,1)
y = DayScaled{k1}(k2,:);
L = y<=1;
hp1{k1,k2} = plot(x(L,k1), y(L), mk{k1}, 'Color',rgb(k2), 'MarkerSize', 10, 'MarkerFaceColor',rgb(k2), 'DisplayName',sprintf('%s \\leq Threshold, Day %d',xtl{k2},k1));
hp2{k1,k2} = plot(x(~L,k1), y(~L), mk{k1}, 'Color',cgttt, 'MarkerSize', 10, 'MarkerFaceColor',cgttt, 'DisplayName',sprintf('> Threshold Day %d',k1));
end
end
xlim([0 3])
% set(gca, 'XTick',1:6, 'XTickLabel',xtl)
set(gca, 'XTick',1:2, 'XTickLabel',compose('Day %d',1:2))
% text(2:3:6, ones(1,2)*min(ylim)-0.075*diff(ylim), compose('Day %d',1:2), 'Horiz','center', 'Vert','top')
hold off
yl = yline(1, '--r', 'Threshold', 'LineWidth',2, 'DisplayName','Threshold');
legend([hp1{:} hp2{:,[2 3]} yl], 'Location','northoutside', 'NumColumns',3, 'FontSize',8)
I’ll keep posting new approaches until I’ve exhausted all the possibilities. The ‘A’-‘C’ designations still appear in the legend. With many more days, though, that could quickly get cumbersome.
.
MattC
2023-3-5
编辑:MattC
2023-3-5
Right so this is what I mean: I do not want to keep tha ‘A’-‘C’ designations
So, what I trying to say is instead of
Day{1} = [10,30,50,75;
30,50,75,95;
15,35,50,75];
Day{2} = [20,40,60,65;
40,70,75,95;
10,30,45,75];
now lets say we only have
Day{1} = [10;
30;
15];
Day{2} = [20;
40;
10];
With this we would only have 3 scaled values per day right? Would it be possible for us to plot them vertically on y axis across a day then? The values for A,B,C would be identified by the color in legend so even they do not exist in x axis label it is fine
So, on a given day either all values remain below the threshold or all above
Star Strider
2023-3-5
O.K., so we¹re now scaling single values?
Scaling single values is straightforward. I don’t even have to change the code, other than to use only one marker for all the points.
Perhaps this —
Scaled = @(data,Th) [data(:) ones(size(data(:)))] * ([Th 1; 0 1] \ [1; 0]); % Scale Data By Threshold
Day{1} = [10;
30;
15];
Day{2} = [20;
40;
10];
A_Threshold = 70;
B_Threshold = 80;
C_Threshold = 85;
Thrshld = [A_Threshold; B_Threshold; C_Threshold];
for k1 = 1:numel(Day)
for k2 = 1:size(Thrshld,1)
DayScaled{k1}(k2,:) = Scaled(Day{k1}(k2,:),Thrshld(k2));
end
end
Day1 = array2table([DayScaled{1}.'], 'VariableNames',{'A','B','C'});
Day2 = array2table([DayScaled{2}.'], 'VariableNames',{'A','B','C'});
ScaledResult = table(Day1,Day2, 'VariableNames',{'Day 1','Day 2'})
ScaledResult = 1×2 table
Day 1 Day 2
A B C A B C
___________________________ _________________________
0.14286 0.375 0.17647 0.28571 0.5 0.11765
x = ones(size([Day{1}],2),1)*(1:size([Day{1}],1));
rgb = 'bgr';
cmy = 'cmy';
xtl = {'A','B','C'};
mk = {'s','d'};
cgttt = [0.9 0.5 0.3];
figure
hold on
for k1 = 1:numel(Day)
for k2 = 1:size(Thrshld,1)
y = DayScaled{k1}(k2,:);
L = y<=1;
hp1{k1,k2} = plot(x(L,k1), y(L), mk{1}, 'Color',rgb(k2), 'MarkerSize', 10, 'MarkerFaceColor',rgb(k2), 'DisplayName',sprintf('%s \\leq Threshold, Day %d',xtl{k2},k1));
hp2{k1,k2} = plot(x(~L,k1), y(~L), mk{1}, 'Color',cgttt, 'MarkerSize', 10, 'MarkerFaceColor',cgttt, 'DisplayName',sprintf('> Threshold Day %d',k1));
end
end
xlim([0 3])
% set(gca, 'XTick',1:6, 'XTickLabel',xtl)
set(gca, 'XTick',1:2, 'XTickLabel',compose('Day %d',1:2))
% text(2:3:6, ones(1,2)*min(ylim)-0.075*diff(ylim), compose('Day %d',1:2), 'Horiz','center', 'Vert','top')
hold off
yl = yline(1, '--r', 'Threshold', 'LineWidth',2, 'DisplayName','Threshold');
legend([hp1{:} hp2{:,[2 3]} yl], 'Location','northoutside', 'NumColumns',3, 'FontSize',8)
.
MattC
2023-3-5
Right I think this is what I want. How do I change the legend for only one color per group?
What I mean is Green for A (any day -1,2,3), Red for B (any day -1,2,3), Blue for C (any day - 1,2,3)
So, this way the legend would only have 4 values
Green - A, Red - B, Blue - C and --- - Threshold
Star Strider
2023-3-5
Perhaps this —
Scaled = @(data,Th) [data(:) ones(size(data(:)))] * ([Th 1; 0 1] \ [1; 0]); % Scale Data By Threshold
Day{1} = [10;
30;
15];
Day{2} = [20;
40;
10];
A_Threshold = 70;
B_Threshold = 80;
C_Threshold = 85;
Thrshld = [A_Threshold; B_Threshold; C_Threshold];
for k1 = 1:numel(Day)
for k2 = 1:size(Thrshld,1)
DayScaled{k1}(k2,:) = Scaled(Day{k1}(k2,:),Thrshld(k2));
end
end
Day1 = array2table([DayScaled{1}.'], 'VariableNames',{'A','B','C'});
Day2 = array2table([DayScaled{2}.'], 'VariableNames',{'A','B','C'});
ScaledResult = table(Day1,Day2, 'VariableNames',{'Day 1','Day 2'})
ScaledResult = 1×2 table
Day 1 Day 2
A B C A B C
___________________________ _________________________
0.14286 0.375 0.17647 0.28571 0.5 0.11765
x = ones(size([Day{1}],2),1)*(1:size([Day{1}],1));
rgb = 'grb';
cmy = 'cmy';
xtl = {'A','B','C'};
mk = {'s','d'};
cgttt = [0.9 0.5 0.3];
figure
hold on
for k1 = 1:numel(Day)
for k2 = 1:size(Thrshld,1)
y = DayScaled{k1}(k2,:);
L = y<=1;
hp1{k1,k2} = plot(x(L,k1), y(L), mk{1}, 'Color',rgb(k2), 'MarkerSize', 10, 'MarkerFaceColor',rgb(k2), 'DisplayName',sprintf('%s \\leq Threshold',xtl{k2}));
% hp2{k1,k2} = plot(x(~L,k1), y(~L), mk{1}, 'Color',cgttt, 'MarkerSize', 10, 'MarkerFaceColor',cgttt, 'DisplayName',sprintf('> Threshold Day %d',k1));
end
end
xlim([0 3])
% set(gca, 'XTick',1:6, 'XTickLabel',xtl)
set(gca, 'XTick',1:2, 'XTickLabel',compose('Day %d',1:2))
% text(2:3:6, ones(1,2)*min(ylim)-0.075*diff(ylim), compose('Day %d',1:2), 'Horiz','center', 'Vert','top')
hold off
yl = yline(1, '--r', 'Threshold', 'LineWidth',2, 'DisplayName','Threshold');
% legend([hp1{:} hp2{:,[2 3]} yl], 'Location','northoutside', 'NumColumns',3, 'FontSize',8)
legend([hp1{1,:} yl], 'Location','northoutside', 'NumColumns',4, 'FontSize',8)
That should scale to more days without much difficulty.
.
MattC
2023-3-5
Is there a way we can change what we see currently when clicking on a particular point in the plot?
When I click on A point for Day1 in the graph I see X 1 and Y 0.1335 but I am interested in showing only A = 0.1335 instead and likewise if it is a B point then the same not matter if it is above the threshold or below
Star Strider
2023-3-5
编辑:Star Strider
2023-3-5
Try this —
Scaled = @(data,Th) [data(:) ones(size(data(:)))] * ([Th 1; 0 1] \ [1; 0]); % Scale Data By Threshold
Day{1} = [90;
30;
15];
Day{2} = [20;
40;
90];
A_Threshold = 70;
B_Threshold = 80;
C_Threshold = 85;
Thrshld = [A_Threshold; B_Threshold; C_Threshold];
for k1 = 1:numel(Day)
for k2 = 1:size(Thrshld,1)
DayScaled{k1}(k2,:) = Scaled(Day{k1}(k2,:),Thrshld(k2));
end
end
% Day1 = array2table([DayScaled{1}].', 'VariableNames',{'A','B','C'});
% Day2 = array2table([DayScaled{2}].', 'VariableNames',{'A','B','C'});
% ScaledResult = table(Day1,Day2, 'VariableNames',{'Day 1','Day 2'})
ScaledResult = array2table(cell2mat(DayScaled), 'VariableNames',compose('Day %3d',1:numel(DayScaled)), 'RowNames',{'A','B','C'})
ScaledResult = 3×2 table
Day 1 Day 2
_______ _______
A 1.2857 0.28571
B 0.375 0.5
C 0.17647 1.0588
x = ones(size([Day{1}],2),1)*(1:size([Day{1}],1));
rgb = 'grb';
cmy = 'cmy';
xtl = {'A','B','C'};
mk = {'s','d'};
cgttt = [0.9 0.5 0.3];
figure
hold on
for k1 = 1:numel(Day)
for k2 = 1:size(Thrshld,1)
hp0{k2} = plot(NaN, 1, mk{1}, 'Color',rgb(k2), 'MarkerSize', 10, 'MarkerFaceColor',rgb(k2), 'DisplayName',sprintf('%s',xtl{k2}));
y = DayScaled{k1}(k2,:);
L = y<=1;
hp1{k1,k2} = plot(x(L,k1), y(L), mk{1}, 'Color',rgb(k2), 'MarkerSize', 10, 'MarkerFaceColor',rgb(k2), 'DisplayName',sprintf('%s',xtl{k2}));
% hp1{k1,k2} = plot(x(L,k1), y(L), mk{1}, 'Color',rgb(k2), 'MarkerSize', 10, 'MarkerFaceColor',rgb(k2), 'DisplayName',sprintf('%s \\leq Threshold',xtl{k2}));
hp2{k1,k2} = plot(x(~L,k1), y(~L), mk{1}, 'Color',rgb(k2), 'MarkerSize', 10, 'MarkerFaceColor',rgb(k2), 'DisplayName',sprintf('> Threshold'));
end
end
xlim([0 3])
% set(gca, 'XTick',1:6, 'XTickLabel',xtl)
set(gca, 'XTick',1:2, 'XTickLabel',compose('Day %d',1:2))
% text(2:3:6, ones(1,2)*min(ylim)-0.075*diff(ylim), compose('Day %d',1:2), 'Horiz','center', 'Vert','top')
hold off
yl = yline(1, '--r', 'Threshold', 'LineWidth',2, 'DisplayName','Threshold');
% legend([hp1{:} hp2{:,[2 3]} yl], 'Location','northoutside', 'NumColumns',3, 'FontSize',8)
% legend([hp1{1,:} hp2{1,:} yl], 'Location','northoutside', 'NumColumns',4, 'FontSize',8)
legend([hp0{:} yl], 'Location','northoutside', 'NumColumns',4, 'FontSize',8)
I changed the ‘Day’ cell arrays slightly to test this. This plots all of them, and any above the threshold, giving them their appropriate groups, regardless.
EDIT — (5 Mar 2023 at 23:44)
Changed the format of the ‘ScaledResult’ table. Code otherwise unchanged.
.
Star Strider
2023-3-5
Please look at my Comment prior to this one, as well.
I’m going to be away for a few minutes.
If my Answer helped you solve your problem, please Accept it!
.
MattC
2023-3-5
I think that helped showing the Threshold values
Is there a way we can change what we see currently when clicking on a particular point in the plot?
When I click on A point for Day1 in the graph I see X 1 and Y 0.1335 but I am interested in showing only A = 0.1335 instead and likewise if it is a B point then the same not matter if it is above the threshold or below
Star Strider
2023-3-5
Not that I am aware of. I can’t find any documentation on creating a GUI that will return that information.
The colours display the memberships.
The ‘ScaledResult’ table has all that information anyway. That’s the reason I created it.
MattC
2023-3-5
Thank you for all the help @Star Strider. If there a way I could put in a recognition for helping me solve this problem I would :)
Star Strider
2023-3-5
As always, my pleasure!
Accepting and voting for it is enough. Reputation points are how recognition is provided.
This will also be for other people with similar problems. For my part, I wrote the ‘Scaled’ anonymous function that I expanded to an anonymous function that can do a bivariate linear regression in a single line.
I also edited the code in my previous Comment so that the ‘ScaledResult’ table now has row names for ‘A’-‘C’, with the variable names being the days. I originally set it up for the earlier data, and now with different single data it needs to have a different format. The code in that Comment is otherwise unchanged.
.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
亚太
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)