Hi
Could you please assist on the process to create a .mat file on Matlab for version R2022a, thanks

댓글 수: 14

John D'Errico
John D'Errico 2022년 12월 28일
편집: John D'Errico 2022년 12월 28일
Is your question how to write a .mat file using a tool like save? If so, then just read the help for save, or read the examples shown.
If your question is how could you write a .mat file as a binary file where you open the file then dump stuff into the file as a binary stream, then no, we can't help you.
Your wording, "From scratch" would imply you want to learn how to write the .mat file, without using a tool like save. But it is not at all clear.
Stephen23
Stephen23 2022년 12월 28일
MAT file format versions 4 and 5 are described in detail here:
Ajay
Ajay 2022년 12월 29일
Hi
I created a .FIS via Fuzzy Logic Toolbox , now I need code for it to run on my MBED Nucleo Board (F411RE) so in order to complete it to get the code I am missing the .mat file which stores the variables .
thanks
Image Analyst
Image Analyst 2022년 12월 29일
편집: Image Analyst 2022년 12월 29일
@Ajay when did you last see it? Who gave it to you or where did you get it from? Or did you make it yourself and "lost" it? Did you check your recycle bin?
Ajay
Ajay 2022년 12월 29일
Hi
I created the .FIS file and I do have it but in order for MATLAB to generate code it needs all the files , sorry I am a beginner in MATLAB and have not done any courses on it so forgive me if my Questions seem "silly" I can share my .fis file if need be , thanks
Ajay
Ajay 2023년 1월 2일
이동: Stephen23 2023년 1월 3일
Hi
I have created a .Fis file , now I need to create the model on Simulink which I did but I am stuck with creating the variables for the .mat file how do i create and what information do I include as I am trying to create slider but it does not give me the variables when I try to connect .I have attached a screenshot of where I am stuck could you please help urgently ,thanks
Ajay
Ajay 2023년 1월 3일
이동: Stephen23 2023년 1월 3일
Hi
Under the Simulink model creation I wish to add a slider to see if my simulation works but I cant seem to connect the slider .
Regards
Ajay
Walter Roberson
Walter Roberson 2023년 1월 3일
In a situation such as this, the first thing I would do would be to try to define what it is that the slider is intended to control.
You would not use a slider to control the rules of a Fuzzy Inference Engine. You might use a slider to control a constant signal, or to control a parameter such as the magnitude of a Gain block -- but your model does not have anything like those.
Ajay
Ajay 2023년 1월 4일
Hi Sir
I wanted to use the slider to test my simulation by moving it to so i can select different tempreture,humidity and wind speed values thanks
Walter Roberson
Walter Roberson 2023년 1월 4일
Since the sliders described above control parameters or variables, you could (if needed) have them control the value of a Constant block that was being fed into the Temperature or whatever block as the input signal.
Ajay
Ajay 2023년 1월 5일
Hi Sir
I tried it please find attached the only issue I have is if I vary my values (on the slider) the output display stays on 50% it should vary accordingly as per change in inputs . Please find attached
Thanking You
Walter Roberson
Walter Roberson 2023년 1월 5일
If I recall correctly triangles with -K- are Gain blocks not constant blocks. And you have no signal feeding the Gain blocks so probably you are magnifying zeros, getting zeros.
Ajay
Ajay 2023년 1월 5일
Hi Sir
So do I include signal gen for each input as well ? as I use the slider to select the desired value input for the sensor as i dont think i can use constant blocks as it not constant values it can be any value as per selection for temp between 0Deg and 100deg Celcius .
Thanking you
Walter Roberson
Walter Roberson 2023년 1월 5일
I have attached an example.
The second computation in the example, producing "WC", has no basis in any physics; I just needed to put in something to show that the code worked.
To use: carefully click on the red bar of one of the two sliders and drag it. When you have both positioned as desired, click Run and observe the (useless) answer.
You might be able to use the same kind of slider style that you used in your code; the important part of the example is that the sliders are adjusting the parameters of constant blocks and the blocks are then acting as input signals.

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

 채택된 답변

Walter Roberson
Walter Roberson 2023년 1월 2일
편집: Walter Roberson 2023년 1월 3일

0 개 추천

In the designer use writeFIS to create a fis file. Do this ahead of time in a separate session.
In the Fuzzy Logic Controller block specify the name of the fis file
When you use Simulink to generate for a target, Simulink will read the fis file and will generate code that will load in appropriate data structures. You will not need to add any code to read a mat file.
Note that at the time the model is generated for target, the content of the file will be locked in to the model. You will not be able to tune or revise the rules in the deployed model, not without rerunning the deployment process.
So you need an interactive matlab session (with appropriate licenses) to build the fuzzy model. The deployed model is stand-alone and does not need any license to run (so go ahead and copy it to all of your embedded systems), but the flip side is that you cannot adjust the FIS rules in the deployed models.

추가 답변 (1개)

Atsushi Ueno
Atsushi Ueno 2022년 12월 28일
이동: Image Analyst 2022년 12월 29일

0 개 추천

You can save variables on your base workspace.
a = 123; b = 456.789;
whos % variables a and b are displayed
Name Size Bytes Class Attributes a 1x1 8 double b 1x1 8 double cmdout 1x33 66 char
save test.mat
clear all
whos % nothing is displayed
load test.mat
whos % variables a and b are displayed again
Name Size Bytes Class Attributes a 1x1 8 double b 1x1 8 double cmdout 1x33 66 char

댓글 수: 2

Ajay
Ajay 2023년 1월 3일
are the above generic variables which I can use ?
Regards
Ajay
Walter Roberson
Walter Roberson 2023년 1월 3일
You can save and load any variables you have in your workspace. save() is not restricted to only handling variables named a and b

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

카테고리

도움말 센터File Exchange에서 Fuzzy Logic in Simulink에 대해 자세히 알아보기

제품

릴리스

R2022a

태그

질문:

2022년 12월 28일

댓글:

2023년 1월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by