Code won't run more then once correctly

2 vues (au cours des 30 derniers jours)
CPdaCE
CPdaCE le 4 Août 2015
Commenté : CPdaCE le 5 Août 2015
When I run the code provided, it works, then when I try to run it again it doesn't go all the way through, spits out data and doesn't create the plots desired. I can clear all, clc and then it runs correctly but it doesn't work again. Please provide feedback when you get the chance. Thank You.
%%Shear Beam - Analysis
clear all
close all
clc
set(0,'DefaulttextFontName','Times New Roman')
set(0,'DefaultAxesFontName', 'Times New Roman')
set(0,'DefaultAxesFontSize',12)
set(0,'DefaultTextFontSize',14)
addpath(genpath('J:/Research/Testing'))
load PS_0SR_192_72_NC_V_data.txt;
%%A. Data Location
data = PS_0SR_192_72_NC_V_data;
time = data(:,1);
mark = data(:,2);
SP1 = data(:,3)*-1;
SP2 = data(:,4)*-1;
SP3 = data(:,5)*-1;
Tilt0 = data(:,6);
Tilt1 = data(:,7);
PB = data(:,8);
T2 = {'SP1 - Quarter Point','SP2 - Midsan','SP3 - Quarter Point'};
SP = [SP1 SP2 SP3];
m1 = min(find(time==0));
m4 = max(find(time==2749.121715));
m2 = (find(time==1176.021716));
m3 = (find(time==1176.221715));
tm_fixed = [m1:m2 m3:m4];
%%B. Load vs Deflection
x = repmat((0:0.25:0.75),3,1);
plot(SP1(tm_fixed),PB(tm_fixed),'color',x(1:3,1))
hold on;
plot(SP2(tm_fixed),PB(tm_fixed),'color',x(1:3,3))
hold on;
plot(SP3(tm_fixed),PB(tm_fixed),'color',x(1:3,4))
axis([0 .2 0 100000])
grid
legend('QuaterPoint','Midspan','EndPoint','Location','southeast');
title('UHPC Load vs Deflection','fontsize',14)
xlabel('Deflection, in. (mm)')
ylabel('Load, kips (kN)')
hold on;
for i =1:3
figure;
co = [x(1:3,1) x(1:3,3) x(1:3,4)];
SPx=SP(:,i);
plot(SPx(tm_fixed),PB(tm_fixed),'color',co(:,i(1,1)))
hold on;
axis([0 .2 0 100000])
grid
legend(T2(1,i),'Location','SouthEast');
title('UHPC Load vs Deflection','fontsize',14)
xlabel('Deflection, in. (mm)')
ylabel('Load, kips (kN)')
hold on;
end
hold off

Réponse acceptée

Image Analyst
Image Analyst le 4 Août 2015
What do you learn when you step through it line by line in the debugger? I bet that would tell you what lines of code it's executing and let you know what the problem is. You didn't attach PS_0SR_192_72_NC_V_data.txt so we can't run your code to test it - you have to do that.
  3 commentaires
Image Analyst
Image Analyst le 5 Août 2015
I ran it several times. All times it produced 4 figures. It never failed to run.
CPdaCE
CPdaCE le 5 Août 2015
Hmm. Weird. Well thanks for you help.

Connectez-vous pour commenter.

Plus de réponses (2)

Walter Roberson
Walter Roberson le 4 Août 2015
In the line before
for i =1:3
change the hold on to hold off
  1 commentaire
CPdaCE
CPdaCE le 4 Août 2015
I tried doing that and it still will only run correctly after I clear all and close all in the command window. Thank you for the help.

Connectez-vous pour commenter.


CPdaCE
CPdaCE le 4 Août 2015
Thank you for the speedy response. Here is the file that I used to build the plots and what not. And I have not tried/heard of the debugger I will try it out. Also, changing hold off did not fix the problem. Let me know if you guys figure anything else out. Thank you again.

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by