Hye Everyone. im newbie in matlab, then i want to ask you all about the simple question.

how i can i can store my data x,y@latitude,longitude and z@height in m-file? and how i can load it?
are like this?
10000 10010 -11
10010 10010 -13
10020 10010 -10
10030 10010 -9
10040 10010 -14
10050 10010 -17
10060 10010 -11
10070 10010 -14
10080 10010 -17
10090 10010 -8
10100 10010 -7
10000 10020 -15
10010 10020 -8
10020 10020 -9
10030 10020 -10
10040 10020 -11
10050 10020 -14
10060 10020 -8
10070 10020 -7
10080 10020 -6
10090 10020 -6
10100 10020 -8
10000 10030 -9
10010 10030 -10
10020 10030 -11
10030 10030 -14
10040 10030 -11
10050 10030 -12
10060 10030 -14
10070 10030 -9
10080 10030 -10
10090 10030 -12
10100 10030 -14

1 Comment

%assuming you have this set of data in an excel file
%you can use the "xlsread" command in MATLAB and assign each collum to a variable
%lets say your file name is "filename"
%lets alos assume the first collumn contains the latitude data
%the second collumn contains the longitude data
%the third collumn contains the data on the height
%%Then here you go
latitude=xlsread('filename.xlsx','A1:A30');
longutide=xlsread('filename.xlsx','B1:B30');
height=xlsread('filename.xlsx','C1:C30');

Sign in to comment.

 Accepted Answer

MyData = [10000 10010 -11
10010 10010 -13
10020 10010 -10
10030 10010 -9
10040 10010 -14
10050 10010 -17
10060 10010 -11
10070 10010 -14
10080 10010 -17
10090 10010 -8
10100 10010 -7
10000 10020 -15
10010 10020 -8
10020 10020 -9
10030 10020 -10
10040 10020 -11
10050 10020 -14
10060 10020 -8
10070 10020 -7
10080 10020 -6
10090 10020 -6
10100 10020 -8
10000 10030 -9
10010 10030 -10
10020 10030 -11
10030 10030 -14
10040 10030 -11
10050 10030 -12
10060 10030 -14
10070 10030 -9
10080 10030 -10
10090 10030 -12
10100 10030 -14];
save('MyData.mat', 'MyData')

8 Comments

thanks sir. but, i cannot load them.
>> load(MyData.m)
Undefined variable "MyData" or function "MyData.m".
load('MyData.mat')
Notice the string must be quoted and notice it is .mat not .m
sorry sir. how i can quote the string? i dont have basic for matlab. this i wanna to try to learn.
>> load('MyData.mat') Error using load Unable to read MAT-file C:\Users\Admin\Desktop\Semester 7\thesis\newUKC\try\MyData.mat: not a binary MAT-file. Try LOAD -ASCII to read as text.
That form of load is fine. What command did you use to save the data from MATLAB?
i dont use any command. i only click save as at the save menu. then i save MyData.mat.
Do not click on "save as" in the save menu. Instead give the command at the command line
save('MyData.mat', 'MyData')

Sign in to comment.

More Answers (1)

You can save your data in a mat-file
v=[1 2 3;4 5 6] % Example
save filename v
To load them use load function

1 Comment

thanks sir. i already try to create my data likes yours but cannot help me. sorry sir

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!