From: Justme on
Hey all,
I'm finally making alot of progress on this script. So thanks to everyones input. I have another question. Sorry if this is a "small" question that I could have just added to my previous posts. I will attach my script. I am trying to calculate for Yaw in my script. The problem lies that when I plot the graph, i'll get points that exceed 360 or below 360 to scale. I would like to have my points go up to 360, and if it pasts 360, be able to take the difference and visa versa..so, basically translate my data and interpolate data and sim data to [0:359] interval and plot them on a 0-360 scale. Does that make sense? I was trying to understand the mod command..I believe that may be able to help me, but I am not sure. Anyone care to share any input and or light?

This is my script..

Dummytext_filename = 'C:\Documents and Settings\Me\InterpTestRead.txt';
FLT_filename = 'C:\Program Files\Me\Airial.txt';
SIM_filename = 'C:\Program Files\Me\simrun.txt';
outputPath = 'C:\Documents and Settings\Me\Myfirstfolder\';
[fltname startflt stopflt startsim stopsim] = textread(Dummytext_filename,'%*s%f%f%f%f%f');
[time1 data1] = textread(FLT_filename,'%f%f');
[time2 data2] = textread(SIM_filename,'%*s%f%*s%*s%f%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s%*s');


for k = 1:length(startflt)
START_FLT = startflt(k);
STOP_FLT = stopflt(k);
START_SIM = startsim(k);
STOP_SIM = stopsim(k);


figure1 = strcat(outputPath,num2str(floor(startflt(k))),'Dataflt');
figure2 = strcat(outputPath,num2str(floor(startflt(k))),'Performance');


%Plotting

%Performance Plot

figure(k+length(startflt))

x = (1:length(performance_data));
ang = linspace(0,3);
plot(ang)

%Criteria
Criterion = 3;
TF = find(performance_data > Criterion); % a logical vector
NumberpointsAboveCriterion = length(TF);
TotalNumberOfPoints = numel(performance_data);
PointsAbove = performance_data(TF);
PercentageAbove = NumberpointsAboveCriterion/TotalNumberOfPoints*100;

plot(x,performance_data,'r*')

hold on

plot(x,Max*ones(length(x),1),'w')
plot(x,Min*ones(length(x),1),'w')
plot(x,Avg*ones(length(x),1),'w')
plot(x,Criterion*ones(length(x),1),'b')

grid on
hold off

hold on
xlabel('Seconds');
ylabel('A diff (Kts)');
legend('A Diff',strcat('Max =',num2str(Max)),strcat('Min =',num2str(Min)),strcat('Avg =',num2str(Avg)),strcat('% > CRIT =',num2str(PercentageAbove)),'Location','SouthOutside','Orientation','horizontal');
% title('Run 1 Maneuver 5.1');
hold off

print(gcf,'-djpeg',figure2);

%flight interp plots

figure(k)

plot(time1b,data1b,'b.')
hold on
grid on
plot(time2b,data2b,'r.')
plot(time2b,flight_interp,'g.')
hold off

hold on
xlabel('Seconds');
ylabel('Airspeed (kts)');
legend('Flight Test','Sim Air','Flight Inter Air','Location','SouthOutside','Orientation','horizontal');
% title('Run 1 Maneuver 5.1');
hold off

print(gcf,'-djpeg',figure1);
end
From: dpb on
Justme wrote:
....

> problem lies that when I plot the graph, i'll get points that exceed 360
> or below 360 to scale. I would like to have my points go up to 360, and
> if it pasts 360, be able to take the difference and visa versa..so,
> basically translate my data and interpolate data and sim data to [0:359]
> interval and plot them on a 0-360 scale. Does that make sense? I was
> trying to understand the mod command..I believe that may be able to help
> me, but I am not sure. Anyone care to share any input and or light?
....

Well, give it a go... :)

mod(yaw,360) will indeed wrap -- question is whether you want to start
from zero again or go back down the scale or not. That's your call...

--
From: Justme on
dpb <none(a)non.net> wrote in message <i0l2ll$3d9$2(a)news.eternal-september.org>...
> Justme wrote:
> ...
>
> > problem lies that when I plot the graph, i'll get points that exceed 360
> > or below 360 to scale. I would like to have my points go up to 360, and
> > if it pasts 360, be able to take the difference and visa versa..so,
> > basically translate my data and interpolate data and sim data to [0:359]
> > interval and plot them on a 0-360 scale. Does that make sense? I was
> > trying to understand the mod command..I believe that may be able to help
> > me, but I am not sure. Anyone care to share any input and or light?
> ...
>
> Well, give it a go... :)
>
> mod(yaw,360) will indeed wrap -- question is whether you want to start
> from zero again or go back down the scale or not. That's your call...
>
> --


Thanks dpb for the quick answer. I tried it in, didn't see my computer explode..lol. It seemed to take in the input but I don't see the change in my graph. I have mod(yaw1, 359)
mod(yaw1, -359)
mod(yaw2, 359)
mod(yaw2, -359)

(I have two yaws being called). And yes, I was going to have it go back down the scale.
From: dpb on
Justme wrote:
....

> ... I don't see the change
> in my graph. I have mod(yaw1, 359)
> mod(yaw1, -359)
> mod(yaw2, 359)
> mod(yaw2, -359)
>
> (I have two yaws being called). And yes, I was going to have it go back
> down the scale.

Depends on what the input signal is (obviously).

I'd suggest experimenting w/ mod() on a small set of data w/ a much
smaller range if you don't follow what its definition is.

Try something like

x=[1:6]';
[x mod(x,3) mod(x,4)]

at the command line and understand what they show and I think all will
become clear.

OBTW, since your talking angular measure, you may find

doc unwrap

of interest/use...

--

From: Steven Lord on

"Justme " <sadsd(a)aol.com> wrote in message
news:i0l419$ns4$1(a)fred.mathworks.com...
> dpb <none(a)non.net> wrote in message
> <i0l2ll$3d9$2(a)news.eternal-september.org>...
>> Justme wrote:

*snip*

> Thanks dpb for the quick answer. I tried it in, didn't see my computer
> explode..lol. It seemed to take in the input but I don't see the change
> in my graph. I have mod(yaw1, 359)
> mod(yaw1, -359)
> mod(yaw2, 359)
> mod(yaw2, -359)
>
> (I have two yaws being called). And yes, I was going to have it go back
> down the scale.

So if we were to have yaw values:

yaw = [359 360 361]

Do you want the results to be:

adjustedYaw = [359 360 359] % "reflected" at 360 -- going "back down the
scale"?

or:

adjustedYaw = [359 0 1] % angle mod 360

In the latter case, you might want to look at the UNWRAP function.

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com