How to rectify the syntax error in Matlab??
Show older comments
I am provided with MATLAB Code for the PSHA of a particular site by my professor. The matlab code that he provided run well in his laptop. However, when I tried to run the code in my laptop, I am not able to get the output as in my professor's laptop. Is it becasue of some syntax error due to MATLAB version or am I missing some file or what is the reason behind me not able to get the required output..
I am getting the following error along with little output.
Error using legend>process_inputs (line 582)
Invalid argument. Type 'help legend' for more information.
Error in legend>make_legend (line 340)
[autoupdate,orient,location,position,children,listen,strings,propargs] = process_inputs(ha,argin); %#ok
Error in legend (line 294)
make_legend(ha,args(arg:end),version);
Error in sub_map_ar_3 (line 52)
h=legend('M4.1-M5','M5.1-M6','M6.1-M7','M7.1-M8','M > 8',3);
Error in HazKTM (line 136)
[a,b,am,amy,natp]=sub_map_ar_3(slon,elon,slat,elat,dmg,dt,xmin,dy,dx, ...
The code provided by my professor is attached here with. The main file is Haz2010.m
2 Comments
The function Haz2010 starts with clear all; . This is a poor programming style and simply a waste of time. I cannot fimd the function HazKTM, which causes the error and on first sight finding sub_map_ar_3 was not possible also. Please make it easier to find the code, which causes the error.
The code can be improve remarkably. E.g.:
[ny,nx]=size(X);
k=0;
for i=1:nx
for j=1:ny
k=k+1;
ZA(j,i)=a(k);
ZB(j,i)=b(k);
ZM(j,i)=amx(k);
end
end
can be simplified to:
ZA = resahpe(a, size(x));
ZB = reshape(b, size(X));
ZM = reshape(amx, size(X));
Searching all line objects by
lineobj=findobj('type','line');
affects the lines in other GUIs also.
Do not use these codes for serious work and do not learn from the programming style of your professor.
dpb
on 2 Jan 2019
Start by verifying you're actually running the same code on your machine as the prof's (he may have updated/corrected his?) and that you have the identical input file(s) and the syntax of the statement that begins the code at the top level is identical to that that runs.
In all likelihood you made a typo or similar problem and what you're comparing isn't actually quite the same...
Answers (0)
Categories
Find more on Seismology in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!