This document contains code for a fuzzy logic GUI application in Python. The application reads temperature data from a file, displays it in a text box, and plots fuzzy membership functions on a canvas to visualize the fuzzy logic system. The code defines a Logicadifusa class with methods to create the GUI controls, retrieve the data points from a file, and draw the membership functions on the canvas.
Original Description:
Original Title
Solucion del examen de sistemas intelgentes 1 de junio 2023.docx
This document contains code for a fuzzy logic GUI application in Python. The application reads temperature data from a file, displays it in a text box, and plots fuzzy membership functions on a canvas to visualize the fuzzy logic system. The code defines a Logicadifusa class with methods to create the GUI controls, retrieve the data points from a file, and draw the membership functions on the canvas.
This document contains code for a fuzzy logic GUI application in Python. The application reads temperature data from a file, displays it in a text box, and plots fuzzy membership functions on a canvas to visualize the fuzzy logic system. The code defines a Logicadifusa class with methods to create the GUI controls, retrieve the data points from a file, and draw the membership functions on the canvas.
Solucion del examen de sistemas intelgentes 1 de junio 2023d
from tkinter import *
import tkinter as tk from tkinter import scrolledtext as st class Logicadifusa(): def __init__(self): self.ventana1=tk.Tk() self.ventana1.title("Logica Difusa") self.ventana1.configure(bg='cyan') self.ventana1.geometry("700x500") self.CrearControles() self.ventana1.mainloop()
def CrearControles(self): self.scrolledtext1=st.ScrolledText(self.ventana1, width=80, height=20) self.scrolledtext1.place(x=200,y=10,width=250, height=100) self.ventana1.btnAbrir=Button(self.ventana1, text="Recuperar Puntos", command=self.recuperar) self.ventana1.btnAbrir.place(x=10,y=10,width=120, height=40) self.ventana1.btnDibujar=Button(self.ventana1, text="dibujar", command=self.dibujar) self.ventana1.btnDibujar.place(x=10,y=60,width=120, height=40) self.canvas1=tk.Canvas(self.ventana1, width=400, height=500, background="black") self.canvas1.place(x=10,y=120,width=650, height=350) def recuperar(self): archi1 = open("temperaturas.txt") self.contenido=archi1.read() archi1.close() f = open("temperaturas.txt") self.matriz=[] fila=0 self.nc=0 self.nf=0 for line in f: self.matriz.append([]) line=line.strip() vcad=line.split('\t') self.nc=len(vcad) for col in range(self.nc): self. matriz[fila].append(vcad[col]) fila=fila+1 self.nf=fila print(self.matriz) self.scrolledtext1.delete("1.0", tk.END) self.scrolledtext1.insert("1.0", self.contenido) def dibujar(self): self.listay=[0.0,1.0,1.0,0.0] self.colores=["blue","green","cyan","yellow","red",]
self.categoria=["FRIA","FRESCA","AGRADABLE","CALIDA","TORRIDA"] self.canvas1.create_text(200,30 ,text="LOGICA DIFUSA", fill="yellow",font=('Arial Black', 18)) self.cx=20 self.cy=200 self.ex=15 self.ey=-100 for fila in range(self.nf): color=self.colores[fila]
self.canvas1.create_text(self.cx+fila*120+50,self.cy+self.ey-40, text=self.categoria[fila], fill=color) for col in range(self.nc-1): x1=float(self.matriz[fila][col]) y1=float(self.listay[col]) x2=float(self.matriz[fila][col+1]) y2=float(self.listay[col+1])