Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

can you people help me ? 1

Status
Not open for further replies.

abaqusian

Materials
Sep 7, 2012
26
HI,

I am trying to learn to work on MATLAB by accessing the numerical data from an excel file. Kindly add your expert opinion.

For example :

in an excel file named "data.xls" , I have three columns:

Code:
Column1     Column2      Column3
0.1            1000       20.05
0.2            1250       21.56
0.3            1500       24.56
0.4            1750       27.14
0.5            2000      -17.25


I want to import above data from excel into matlab and do following things , then plot them .

(1) Add column1 and column3 , store that as a new column or array.
(2) plot that array against column2 in matlab .

I have a more number of data and I have to do many trial and error methods to get the right plot. (may be you can say as fitting the curve too ) . I am tired doing it in excel ..., I want to do in matlab.

Can anyone please suggest the way?

Thanks from Basic Matlab Learner.
 
Replies continue below

Recommended for you

I'd start by saving your Excel data a CSV file (text data), which will make it easier to work with in Matlab... maybe "data.csv". From there, you should be able to read your data into Matlab fairly easily with the dlmread function as a big array. One of the first things to become familiar with when learning Matlab is how to deal with arrays. For what you've given above, you might do something like this:
Code:
clear;clc;close all;
DATA = dlmread('data.csv',',',1,0)'; %Read data from file into matrix and transpose, skip the first row (assumes headers)
C1 = DATA(1,:);   %Variable for column 1
C2 = DATA(2,:);   %Variable for column 2
C3 = DATA(3,:);   %Variable for column 3

xx = C1+C3;       %Add column 1 and column 3, set to variable xx
yy = C2;          %Set column 2 to variable yy for readibility

%Plot xx and yy with circular markers and a solid, red line
plot(xx,yy,'o-','LineWidth',2,'Color','r');
 
Hi , i need help please to read file (Python) on matlab.
 
Your question is not making sense to me. Are you running Python or Matlab? Have you read the help files? Have you looked at the Mathworks site?

TTFN
faq731-376
7ofakss

Need help writing a question or understanding a reply? forum1529
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor