How to extract variable from met office .nc file by lat ang long

조회 수: 4 (최근 30일)
Ryan Dempsey
Ryan Dempsey 2018년 8월 27일
답변: Akshay Khadse 2018년 8월 30일
I'm trying to obtain figures from the Clim5 HadGEM2 model for x and y winds up to 2100, I have downloaded the data and I'm attempting to extract through matlab but I am getting the errors. Ive adapted a old script to try and work out a fuction but i get a invalid syntax error message. any advice?
function[va,year]= ncread('va2005.nc','va'); % year=((1:299)-0.5)/12+2005; ilon=1+round(mod(rlon+360,360)); if(ilon == 361); ilon=1; end jlat=1+round(rlat+90); % fid=ncread('va2005.nc'); temp=ncread(fid,360*181*299,'real*4=>real*4'); fclose(fid); temp=reshape(temp,360,181,299); va=squeeze(temp(ilon,jlat,:)); end
  댓글 수: 1
madhan ravi
madhan ravi 2018년 8월 27일
편집: madhan ravi 2018년 8월 27일
Click the paper clip button and upload .nc file so that the code can be debugged.

댓글을 달려면 로그인하십시오.

답변 (1개)

Akshay Khadse
Akshay Khadse 2018년 8월 30일
The first line of your code must declare the function name, input and output arguments. However, here you've put char arrays instead of variable names. A correct function declaration would be something like
function [va,year] = ncread(fileName, optionVal)
instead of
function [va,year] = ncread('fileName', 'optionVal')
Please refer to documentation for "function" here .
In future, you might want to consider Code Analyzer messages showing up when you hover over orange or red markers in right hand side vertical bar of the MATLAB editor window to improve the code.

카테고리

Help CenterFile Exchange에서 Climate Science and Analysis에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by