Randomly read in data and feed into fuzzy logic file

1 回表示 (過去 30 日間)
Alex kew
Alex kew 2018 年 4 月 18 日
コメント済み: Alex kew 2018 年 4 月 18 日
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.
  1 件のコメント
Alex kew
Alex kew 2018 年 4 月 18 日
the input has the following format:
24
23
34
56
32
89

サインインしてコメントする。

採用された回答

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".
Alex kew
Alex kew 2018 年 4 月 18 日
I see, I will try it out.
Thanks again for your help.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeScripts についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by