You are Here: Home

Matlab help required

Announcements Posted on
TSR's new app is coming! Sign up here to try it first >> 17-10-2016
1. not sure if in the right place

Is anybody here proficient in MATLAB?

There's some help I require and I can't get a response from anybody on the official forum.
2. What are you having problems with?
3. I know a bit.
ServantOfMorgoth
13 1 20 8 42

Guys can you help?
5. (Original post by BlueSam3)
What are you having problems with?
Would I be able to PM you?
6. (Original post by Eternalflames)
ServantOfMorgoth
13 1 20 8 42

Guys can you help?
I already told him im ok at best with matlab. I hope he gets help though.
7. Sure, PM me if you like. Or just post it here.
8. Spoiler:
Show
% Practical 9
% A script to plot two 3D waves.

clear
%Define the total time for simulation
T_total=10;
%Set the computation increment
dt=0.1;
%calculate the number of steps
ntstep=T_total/dt+1;
%Define Input Waves
alphaa=1; %velocity of wave a
alphab=2; %velocity of wave a

fa=1; %frequency of wave a
fb=0.5; %frequency of wave b
ampa=6; %amplitude of wave a in cm
ampb=3; %amplitude of wave b in cm

%set the source depth
depth=1;

%Calc wave parameters using input
Ta=1/fa; %period of wave a
Tb=1/fb; %period of wave a
wa=2*pi*fa; %angular frequency of wave a
wb=2*pi*fb; %angular frequency of wave b
la=Ta*alphaa;%wavelength of wave a
lb=Tb*alphab;%wavelength of wave b
ka=2*pi/la; %wavenumber of wave a
kb=2*pi/lb; %wavenumber of wave b

x=(-1010); %x
y=(-1010); %y
z=(-200); %z
t=zeros(length(x),length(y), length(z)); %start time
% setup the figure
figure(1);

%label axes
xlabel('Distance (m)');
ylabel('Distance (m)');
zlabel('Depth (m)');
hold on
[X,Y,Z]=meshgrid(x,y,z);
R=sqrt(X.^2+Y.^2+(Z+depth).^2);
%loop over nsamp
for n=1:ntstep
t=t+dt; %time
arga=wa*t-ka*R; %argument of wave a
argb=wb*t-kb*R; %argument of wave b
a=ampa*sin(arga)./max(1,R);
a(R>t.*alphaa)=0; % causality condition
a(R<t.*alphaa-la/2)=0; % limit lenght of input wave to one half cycle
b=ampb*sin(argb)./max(1,R);
b(R>t.*alphab)=0; % causality condition
b(R<t.*alphab-lb/2)=0; % limit lenght of input wave to one half cycle

figure(1);
hold off;

wf=a+b;
slice(X,Y,Z,wf,x,y,z);
axis square;
caxis([0,1]);
colormap([[0:0.1:1]',zeros(length([0:0.1:1]'),1),zeros(length([0:0.1:1]'),1)]);
col=colorbar;
alpha(0.05);
hold on;
%label axes
xlabel('Distance (km)');
ylabel('Distance (km)');
zlabel ('Depth (km)');
ylabel(col,'Amplitude (cm)'); % label the colour bar

title(strcat('time = ', num2str(t(1)), ' s'));
pause (dt);

end

I need to add a contour plot to show the displacement at the surface of the animation (so only in X-Y plane - I'll attach a photo to clarify if required) to show displacement. Using contour(X,Y) doesn't quite work.

Then I need to add a subplot to show displacement against time at the surface at any chosen point [X,Y,0]
9. Nobody?
10. Okay i've figured it out...

but now I'm stuck on something else.

Not that any of you care.

11. (Original post by hezzlington)
Okay i've figured it out...

but now I'm stuck on something else.

Not that any of you care.

Next time you have issues talk to me. I will surely help!
Next time you have issues talk to me. I will surely help!
How good are you? I'm planning to do my final year project on matlab and I'm pretty rubbish at it. I'd need loads of help 😅

Posted from TSR Mobile
Next time you have issues talk to me. I will surely help!
i have issues can you help me

Register

Thanks for posting! You just need to create an account in order to submit the post
1. this can't be left blank
2. this can't be left blank
3. this can't be left blank

6 characters or longer with both numbers and letters is safer

4. this can't be left empty
1. Oops, you need to agree to our Ts&Cs to register

Updated: May 8, 2016
TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Today on TSR

How does exam reform affect you?

From GCSE to A level, it's all changing

Who would you like to thank?

Poll
Study resources

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE

Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.