Randomly read in data and feed into fuzzy logic file

1 次查看(过去 30 天)
Hi, I am new to Matlab, and I have 2 questions.
1. I have a text file, it has 50 lines, each line has a value(e.g. 23). Now I want to randomly read one line, which means read one number randomly from this text file by using a control.m file, and feed into another fuzzy logic file (fuzzy.fis), which function should I use to achieve this goal?
2. In Matlab, do we have functions? like in Java we got method, which can be called within one class, and one class can contain many methods, do we have this kind of structure in Matlab?
Thanks for your answers.

采纳的回答

Walter Roberson
Walter Roberson 2018-4-18
1) I do not recommend reading lines at random until the datasets become fairly large and the reading is going to happen a number of times. I recommend instead that you read all of the data and then index into the data randomly at need.
2) yes, MATLAB supports creating classes with methods. The primary keyword to look for is "classdef"
  3 个评论
Walter Roberson
Walter Roberson 2018-4-18
No. It is possible to create static methods of a class that do not require instantiation of an object. The route you described is the most typical, but it is not strictly required.
The kind of situation that you outlined would probably be served by coding the class constructor to permit a file name. But if the point were to immediately pull the data out of the resulting object then a static method would make more sense.
In the case where you want to put together libraries of functionality (for example a library of routines that read in various file formats and convert them to image arrays, then you could consider instead creating a MATLAB "package".

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scripts 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by