Hi, I have 5 sets of data and I want to write a script that reads my 5 matrices (1x21 double) and displays a single figure that plots the mean error (y) against the gain (x) in decibel. The output of my script should has:
  • The lines for each segment should be displayed using a different color. With point where is the value on the segment.
  • A legend should be included indicating wich line corresponds to wich segment
  • Each segment should has his linear fit (courve fitting) in wich I can find the ratio between the axes
I think I have to use iteraction for a solution of this kind, but I'm not sure how.
These are my 5 data:
err20 = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1.08935539299999,2.06473429585112,5.31643514302866,12.1807063663099,23.4911626896201,37.8143988479465,53.0667200958471];
err40 = [1,1,1,1,1,1,1.00980392156863,1.21923952036955,1.83719863383950,3.35132045800776,6.15310998083444,10.4540779879203,16.3935058175317,24.4567825083250,34.2731876493287,44.8404803207833,56.1569894419756,67.9621753642978,80.3418716316936,92.6177152673935,105.509145868874];
err60 = [1.39130582788671,2.06089077044959,3.06870791245791,4.79824204787542,7.43102274858528,11.1839078762097,15.8879812010210,21.5982089544676,28.3128632729741,36.0451923666447,44.3639384800055,53.0905553702049,62.0750621155379,70.5611743877611,79.2822679481440,87.4151859346590,95.2561517964825,102.939651014533,111.592224212783,119.481125788707,128.101212449710];
err80 = [17.4311417284922,22.2395558126501,27.9265106941469,34.2412676054684,40.8661898327012,47.9425873245325,55.0569858602196,62.0452743182326,68.6517414695066,75.0178392624680,81.3553772590478,87.8836526599804,93.1726477983694,99.2482660012320,104.954811955097,110.618897123263,116.985855082487,123.136684599450,129.996356750259,137.015229368536,144.682941495957];
err100= [50.0098577942206,55.6474590816719,61.3114187709398,66.7658549295944,72.0226315556860,76.6917932491624,81.7675527655915,86.5206979973362,90.9380438970932,95.6093452209315,99.8809271502719,104.517882995723,109.232695936831,113.888646043589,118.823549750783,124.212683308618,129.481920951591,135.262067967506,141.525996933700,147.328685524455,153.893747639987];

 채택된 답변

Chetan Bhavsar
Chetan Bhavsar 2021년 10월 2일
편집: Chetan Bhavsar 2021년 10월 3일

1 개 추천

@Agnese Chini Is this fulfill your requirement?
err20 = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1.08935539299999,2.06473429585112,5.31643514302866,12.1807063663099,23.4911626896201,37.8143988479465,53.0667200958471];
err40 = [1,1,1,1,1,1,1.00980392156863,1.21923952036955,1.83719863383950,3.35132045800776,6.15310998083444,10.4540779879203,16.3935058175317,24.4567825083250,34.2731876493287,44.8404803207833,56.1569894419756,67.9621753642978,80.3418716316936,92.6177152673935,105.509145868874];
err60 = [1.39130582788671,2.06089077044959,3.06870791245791,4.79824204787542,7.43102274858528,11.1839078762097,15.8879812010210,21.5982089544676,28.3128632729741,36.0451923666447,44.3639384800055,53.0905553702049,62.0750621155379,70.5611743877611,79.2822679481440,87.4151859346590,95.2561517964825,102.939651014533,111.592224212783,119.481125788707,128.101212449710];
err80 = [17.4311417284922,22.2395558126501,27.9265106941469,34.2412676054684,40.8661898327012,47.9425873245325,55.0569858602196,62.0452743182326,68.6517414695066,75.0178392624680,81.3553772590478,87.8836526599804,93.1726477983694,99.2482660012320,104.954811955097,110.618897123263,116.985855082487,123.136684599450,129.996356750259,137.015229368536,144.682941495957];
err100= [50.0098577942206,55.6474590816719,61.3114187709398,66.7658549295944,72.0226315556860,76.6917932491624,81.7675527655915,86.5206979973362,90.9380438970932,95.6093452209315,99.8809271502719,104.517882995723,109.232695936831,113.888646043589,118.823549750783,124.212683308618,129.481920951591,135.262067967506,141.525996933700,147.328685524455,153.893747639987];
gain =1:21;
plot(gain,err20,'redo')
hold on
plot(gain,err40,'green*')
hold on
plot(gain,err60,'blue+')
hold on
plot(gain,err80,'cyanx')
hold on
plot(gain,err100,'magentad')
legend('err20','err40','err60','err80','err100')
ylabel('Error')
xlabel('Gain')

댓글 수: 5

HelpAStudent
HelpAStudent 2021년 10월 3일
How can I have also the line beetween the point?
Chetan Bhavsar
Chetan Bhavsar 2021년 10월 3일
편집: Chetan Bhavsar 2021년 10월 3일
@Agnese Chini add - after color in command like below
Please click the "Accept this answer" link if it fullfilled your requirement.
err20 = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1.08935539299999,2.06473429585112,5.31643514302866,12.1807063663099,23.4911626896201,37.8143988479465,53.0667200958471];
err40 = [1,1,1,1,1,1,1.00980392156863,1.21923952036955,1.83719863383950,3.35132045800776,6.15310998083444,10.4540779879203,16.3935058175317,24.4567825083250,34.2731876493287,44.8404803207833,56.1569894419756,67.9621753642978,80.3418716316936,92.6177152673935,105.509145868874];
err60 = [1.39130582788671,2.06089077044959,3.06870791245791,4.79824204787542,7.43102274858528,11.1839078762097,15.8879812010210,21.5982089544676,28.3128632729741,36.0451923666447,44.3639384800055,53.0905553702049,62.0750621155379,70.5611743877611,79.2822679481440,87.4151859346590,95.2561517964825,102.939651014533,111.592224212783,119.481125788707,128.101212449710];
err80 = [17.4311417284922,22.2395558126501,27.9265106941469,34.2412676054684,40.8661898327012,47.9425873245325,55.0569858602196,62.0452743182326,68.6517414695066,75.0178392624680,81.3553772590478,87.8836526599804,93.1726477983694,99.2482660012320,104.954811955097,110.618897123263,116.985855082487,123.136684599450,129.996356750259,137.015229368536,144.682941495957];
err100= [50.0098577942206,55.6474590816719,61.3114187709398,66.7658549295944,72.0226315556860,76.6917932491624,81.7675527655915,86.5206979973362,90.9380438970932,95.6093452209315,99.8809271502719,104.517882995723,109.232695936831,113.888646043589,118.823549750783,124.212683308618,129.481920951591,135.262067967506,141.525996933700,147.328685524455,153.893747639987];
gain =1:21;
plot(gain,err20,'red-o')
hold on
plot(gain,err40,'green-*')
hold on
plot(gain,err60,'blue-+')
hold on
plot(gain,err80,'cyan-x')
hold on
plot(gain,err100,'magenta-d')
legend('err20','err40','err60','err80','err100')
ylabel('Error')
xlabel('Gain')
HelpAStudent
HelpAStudent 2021년 10월 3일
Thank you very much, Is there any way to know the slope of the lines roughly?
Maybe like this
p = polyfit(gain,err100,1) ;
slope5 = p(1)
HelpAStudent
HelpAStudent 2021년 10월 4일
Thank you, it works!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

제품

릴리스

R2020b

질문:

2021년 10월 2일

댓글:

2021년 10월 4일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by