Error in lplot (line 3) Figure = plot(shifts,data);

2 views (last 30 days)
Using this script:
cd('/Users/Ewan/Desktop/MATLAB/Extracted data')
load('PC3_D55')
load('PNT2_D55')
quality control (run for each data set)
close all
lplot(shift, PC3_D55); title('PC3');
[shift_cut, PC3_D55] = AJ_QT_cutrange(shift, PC3_D55);
quality control (run for each data set)
close all
lplot(shift, PNT2_D55); title('PNT2');
[shift_cut, PNT2_D55] = AJ_QT_cutrange(shift, PNT2_D55);
scale to 2935 peak
a=scale2935(PC3_D55);
b=scale2935(PNT2_D55);
plot to compare data sets mean for each individual data set
Black = caz_rgb_chart('Black');
Magenta = caz_rgb_chart('Magenta');
Lime = caz_rgb_chart('Lime');
Red = caz_rgb_chart('Red');
Blue = caz_rgb_chart('Blue');
Purple = caz_rgb_chart('Purple');
figure;
h1= plot(shift_cut, mean(a), 'Color', [Red]);
set(h1, 'LineWidth',2);
hold on
h2 = plot(shift_cut, mean(b), 'Color', [Blue]);
set(h2, 'LineWidth',2);
hold off
legend('PC3 3','PNT2 3');
set(legend,'Color','none');
axis('tight')
set(gca,'box','off')
set(gcf,'Color',[1 1 1])
xlabel('Raman Shift/cm^-^1','FontWeight','bold','FontSize',16,'FontName','Arial')
ylabel('Counts', 'FontWeight','bold','FontSize',16,'FontName','Arial')
set(gca,'FontWeight','bold','FontSize',16,'FontName','Arial');
group all data sets from same conditions together
DMSO_all=[a];
TOFA_all=[b];
plot to compare data sets mean by condition
Black = caz_rgb_chart('Black');
Magenta = caz_rgb_chart('Magenta');
Lime = caz_rgb_chart('Lime');
Red = caz_rgb_chart('Red');
Blue = caz_rgb_chart('Blue');
Purple = caz_rgb_chart('Purple');
figure;
h1= plot(shift_cut, mean(DMSO_all), 'Color', [Red]);
set(h1, 'LineWidth',1);
hold on
h2 = plot(shift_cut, mean(TOFA_all), 'Color', [Blue]);
set(h2, 'LineWidth',1);
hold off
legend('PC3','PNT2');
set(legend,'Color','none');
axis('tight')
set(gca,'box','off')
set(gcf,'Color',[1 1 1])
xlabel('Raman Shift/cm^-^1','FontWeight','bold','FontSize',16,'FontName','Arial')
ylabel('A.U.', 'FontWeight','bold','FontSize',16,'FontName','Arial')
set(gca,'FontWeight','bold','FontSize',16,'FontName','Arial');
ratio1 = 2850/2935
[ratio1_DMSO]=extract_ratio_2850_2935_AJ(DMSO_all);
[ratio1_TOFA]=extract_ratio_2850_2935_AJ(TOFA_all);
ratio2 = 2880/2935
[ratio2_DMSO]=extract_ratio_2880_2935_AJ(DMSO_all);
[ratio2_TOFA]=extract_ratio_2880_2935_AJ(TOFA_all);
I keep getting the ERROR:
Error using plot
Vectors must be the same length
Error in lplot (line 3)
Figure = plot(shifts,data);
Funny thing is that it works for some .mat files I run and often I get this error.
I cant work out why...please help?
  5 Comments
Ewan Hislop
Ewan Hislop on 31 May 2019
Im not sure what is being asked sorry
Steven Lord
Steven Lord on 31 May 2019
Set an error breakpoint to pause when MATLAB throws an error.
Run your code.
When MATLAB pauses due to that error, look at the size of the shifts and data variables. They won't be the same length.
You will need to determine, by examining the data in your program, why the variables aren't the same length. At the very least you'll probably be able to tell (assuming you're looping over a list of file names) which file has the data of unexpected length.
Since lplot doesn't appear to be a function in a MathWorks product, you may want to either contact the author of that function or post a link where people on Answers can see what it does (don't post the function itself without the author's permission) and we may be able to see if it does something unusual that would cause this error.

Sign in to comment.

Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!