What does the dot between two variables do?

18 vues (au cours des 30 derniers jours)
Leonardo Elizondo
Leonardo Elizondo le 10 Mai 2016
Modifié(e) : James Tursa le 10 Mai 2016
What does the dot do in something like p1.p2

Réponses (1)

James Tursa
James Tursa le 10 Mai 2016
Modifié(e) : James Tursa le 10 Mai 2016
It depends on what p1 is. If p1 is a struct variable, p2 would be a field of p1. If p1 was a classdef OOP object, then p2 could be a property or a method of p1. E.g., for a struct:
>> p1.p2 = 1:3 % <-- Create a struct called p1 with one field called p2
p1 =
p2: [1 2 3]
>> class(p1) % <-- The class of p1
ans =
struct
>> class(p1.p2) % <-- The class of the field element p2
ans =
double
>> p1
p1 =
p2: [1 2 3]
>> p1.p2
ans =
1 2 3

Catégories

En savoir plus sur Structures dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by